loonywizard / js-confetti

JS Confetti library that supports emojis 🦄 🎉 ⚡️
https://loonywizard.github.io/js-confetti/
MIT License
1.13k stars 48 forks source link

Don't schedule a `requestAnimationFrame` if there is nothing to animate #36

Closed grork closed 2 years ago

grork commented 2 years ago

With this change, a requestAnimationFrame is not scheduled unless there is active confetti to animate.

This is because when idle, the browser will continue to do work, even though there is no work to do.

However, adding confentti will restart the loop if it is not currently running. If it is, no additional frames are scheduled.

grork commented 2 years ago

I'll rebase & fix up this change after #37 is merged (or, the other way, whichever is merged first)

loonywizard commented 2 years ago

@grork thank you! now everything works amazing, I will merge this now, and publish everything (#36 #37 and #38) after #37 review