Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

OnLeave destroy #86

Closed Stoske98 closed 4 years ago

Stoske98 commented 4 years ago

Hey guys, this might be begginer question but I just started with Highway js. Is there any way to destroy function onLeave({ .. .});

Something like: customFunction.destroy();

Anthodpnt commented 4 years ago

Hey @Stoske98,

Why would you want to destroy de onLeave method? Can you please give us a use case where it's required for you to destroy this method?

Best regards, Anthodpnt

Stoske98 commented 4 years ago

Thanks for the response. I probably formulated the question in a bad way. I have PIXI js application that I draw on canvas using a function. I call that function onEnter method, but when I leave canvas and all the code remains even if I don't have them on another page, so I guess I need somehow to destroy that function inside of onLeave method. I hope I was clearer this time.

Anthodpnt commented 4 years ago

Indeed, all the code running that doesn't need to be run on other pages has to be destroyed or stopped in the onLeave or onLeaveCompleted method. Those methods are used mostly for this use case, avoid useless code to keep running on all pages after a navigation. It's your job to destroy what has to be destroyed though.

Stoske98 commented 4 years ago

I understand that, but simply run .destroy() don't help. I tried this way https://github.com/Dogstudio/highway/issues/57 but without results. Canvas still remains on-page, and simple .remove(); from DOM doesn't work since there is still all the code running in the background.

Anthodpnt commented 4 years ago

Well, unfortunately this has nothing to do with Highway. The problem seems to come for your own code running in the onLeave method of the renderer. We won't be able to help you more on this one. Maybe with a snippet of all the code you have in the onLeave method. I'll have to close this issue without more informations since this isn't an issue coming from Highway.

Anthodpnt commented 4 years ago

Issue closed because no more informations has been provided.