Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup / Destroy #296

Open
somegooser opened this issue Nov 25, 2022 · 5 comments
Open

Cleanup / Destroy #296

somegooser opened this issue Nov 25, 2022 · 5 comments

Comments

@somegooser
Copy link

Is there any way to destory / cleanup countup after use?

Thanks!

@inorganik
Copy link
Owner

you can simply delete it:

const countUp = new CountUp('targetId', 5234);
countUp.start();

and later

delete countUp;

@somegooser
Copy link
Author

Thank you for the comment but will this also delete events attached via enableScrollSpy?

@inorganik
Copy link
Owner

good point. You could do

delete window['onScrollFns'];
window.onscroll = null;

I really don't think you're going to get any performance wins by doing that.

@inorganik inorganik reopened this Nov 25, 2022
@inorganik
Copy link
Owner

However if you deleted your countUp instance, and it was using scroll spy, you could get a null pointer exception, so I could add a detach method.

@inorganik
Copy link
Owner

This is published in v2.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants