Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Faaiz

Having trouble restarting TimelineMax on button click

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi, so with the help of you guys, I was able to create something, but I'm still stuck on one small thing, I can't seem to restart the animation when clicked by a button, after clicking the second button, when the first button is clicked(in the pen), the animation just slows down, and text overlaps each other, any help would be really appreciated, thanks again!

See the Pen VGOYjb by goprime (@goprime) on CodePen

Link to comment
Share on other sites

I'm not really sure what should be happening here, but you're creating your timeline every time you click the section 1 button. This is causing overwrites and everything will look funky. I think you meant to make the master a global variable and restart it on click. Please make these changes to the end of your code.

 

$('#btn1').click(function(){
  $('#c2').css('display','none');
  $('#c1').css('display','block');
 master.restart();
});

we3dxAnimation();

 

Happy tweening.

  • Like 6
Link to comment
Share on other sites

nice work, mikel! Solves the problem with very little code. The design is cool too!

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×