Forum Discussion
An Easy-to-Use Animated Menu Using GSAP
Thanks Robert. You probably are encountering an issue with the resize handler. As this is designed, the resize event handler needs to be cancelled before leaving the slide. If it isn't, it continues to try to monitor page elements that no longer exist after you change to a new slide, which is a problem. The side menu doesn't provide a simple way to trigger an action before moving to the next slide; it just jumps.
If you look at the triggers attached to the buttons jumping between the design options, for example:
you'll see that before leaving the current slide, a request is made to end the resizing function (by setting the menuEndResiser variable to true and then toggling the triggerMenu variable). You need to complete these two steps before moving to the next slide, otherwise the resizer function creates an error. For instance, if you place a new button on the slide with these two triggers attached, and then click it before selecting a new slide from the side menu then it will work properly.
The easy fix is to not use the side menu. Otherwise, you could approach it in a few ways:
- Set up some way to trigger these before the slide change
- Possbily trigger these at the very begining of a new slide, before anything else happens
- This may require some slight code modification
- Improve the resize handler to catch errors (like undefined elements) and self-cancel using the reference to the handler when this happens
- This would assume a slide change happened and get rid of the old event handler automatically
- Change the code to allow for mulitple resize handlers, one for each new slide
- Would still need some error catching to handle missing elements, and other code updates
If I had to do it, I would probably try to make #3 work (if you had to have a side menu).
Thanks Nathan. I will give these a try and see if I find something that works. I appreciate the quick response.