drawcall / Proton

Javascript particle animation library
https://drawcall.github.io/Proton/
MIT License
2.42k stars 275 forks source link

Velocity/Speed of the particles doubles on every page load #57

Closed developeron29 closed 6 years ago

developeron29 commented 6 years ago

if i am loading the particles using a script on a page route. Every time i route to that page, the speed of the particles double, than what it was before. Even if i destroy the proton element or remove all emitters and behaviours after page unload

drawcall commented 6 years ago

Can you describe your scenario in detail or provide your demo code, I think you should run the destroy method when the router is unloaded

developeron29 commented 6 years ago

Thanks @a-jie Yes, i tried to run destroy when the router is unloaded, didn't help

My scenario is i am using Angularjs to load routes asynchronously. Each time a page route is loaded, it loads the proton script as well, which re-instantiates the proton code, to generate an emitter, and attach it to the defined proton element. The speed/velocity of particles doubles on every time, we re-route to the page, where we are instantiating the proton script

I am guessing, loading the route page asynchronously might be the problem

drawcall commented 6 years ago

Please provide your demo code, you may have repeatedly registered the render listener function

developeron29 commented 6 years ago

That is correct, checking and loading the script file only once, solved it, Thanks!