-
-
Notifications
You must be signed in to change notification settings - Fork 889
How to properly destroy the mojs object after a Burst animation has finished playing? #144
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
Comments
Hey @Darko, thanks for the issue! Can you tell me more about your intentions, so I can help with the best solution for you?
But I suspect you want to do something different, so please share your intents. |
Wow that was a really fast response 😄 Is there a proper way to do this, or I'd need to figure out the duration of the animation and then using |
I see this makes sense. In the best case, you would create just one burst instance and then reuse it with help of the // instead, create one burst instance
const burst = new mojs.Burst({});
// on click
buttonEl.addEventListener('click', function(e) {
// tune burst's `x` and `y` to event's `x` and `y`
burst.tune({ x: e.pageX, y: e.pageY })
// replay it
.replay();
}); There is a small demo with the code snippet above. In your case, you can have 5 burst instances - one for each star. |
Alternatively, you can just set const burst = new mojs.Burst({
parent: starEl // send the burst inside start
});
starEl.addEventListener('click', function() {
burst.replay();
}); Demo. |
I ended up doing this:
|
May be it would be cool to have a function like
|
What is the best way to properly destroy the DOM element after an animation has finished playing?
I saw a .then method in the API but doesn't seem to be doing anything.
Sorry if this was asked before, or if there's already something in the API, I couldn't find anything 😩
The text was updated successfully, but these errors were encountered: