janpaepke / ScrollMagic

The javascript library for magical scroll interactions.
http://ScrollMagic.io
Other
14.91k stars 2.17k forks source link

Remove Scenes #988

Closed zangab closed 2 months ago

zangab commented 3 years ago

Hi, why is there no removeScenes() function provided? The added scenes are all saved in the controller (_sceneObjects) so it should be quite easy to add this function.

Cheers.

shikkaba commented 1 year ago

@zangab There is one. Controller.removeScene(scene) removes the scene from the controller until it is added again. https://scrollmagic.io/docs/ScrollMagic.Scene.html#remove

zangab commented 1 year ago

I was looking for something that removes all scenes without the need of a reference to existing ones. if u call Controller.removeScene(scene) you always need the scene and it's just removing one. but if I have 2 or 3 scenes, I need to remove them one-by-one and that's the actual issue.

shikkaba commented 1 year ago

@zangab I realize you had messaged a long time ago, so sorry for that. I just like to answer things just in case someone else has the same issues.

If you need to destroy all the scenes, it might be easier to destroy the entire controller with it set to true. That would accomplish the same thing as all scenes would be destroyed. controller.destroy( true ); Destroying without true does not destroy the scenes. https://scrollmagic.io/docs/ScrollMagic.Controller.html#destroy

For anyone who missed the earlier option: If anyone wanted to do it for specific scenes, so with knowing what the scenes are, you can also remove scenes from the controller controller.removeScene([scene, scene2, scene3]);