Share Posted November 26, 2019 Hello guys, I am trying to animate a menu, with two different timelines (open and close). Everything works fine. There still one little issue I need to solve: After closing the menu and toggle the button to open the menu, the open-animation doesn't work / run. Here is my code: menuIcon.addEventListener('click', MenuAnimation); var menuState = 0; function MenuAnimation(){ if(menuState == 0 ){ menuState = 1; tl.play(); } else if(menuState == 1){ tl_remove.play(); menuState = 0; } } Thank you in advance. Regards Daniel See the Pen abbgBKq by Daniel2024 (@Daniel2024) on CodePen Link to comment Share on other sites More sharing options...
Share Posted November 26, 2019 Hey @Daniel2024, The characteristic of play() : by default playback begins from wherever the playhead currently is. //begins playing from wherever the playhead currently is: myAnimation.play(); //begins playing from start: myAnimation.play(0); See the Pen JjjQEPm by mikeK (@mikeK) on CodePen Happy tweening ... Mikel 4 Link to comment Share on other sites More sharing options...
Author Share Posted November 26, 2019 thank you Mikel! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now