Jump to content
GreenSock

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

Pausing timeline when complete

Recommended Posts

Hey guys,

 

I want to pause the timeline when it's completed.

 

tl = new TimelineMax({repeat: -1, paused: true});
    
    tl
        .to(dummy, 0.5, {x: '+=60', ease:Power3.easeOut}, 0.5)
        .addPause()
        .to(dummy, 0.5, {x: '-=60', ease:Power3.easeOut}, 1.5)
        .addPause();

 

The first addPause() works, the one at the end doesn't effect the timeline at all.

 

The timeline is paused on load, a click on a button starts it. It pauses on the first addPause, a buttons starts it again but it doesn't pause on the last addPause.

 

I hope it's somehow clear what I'm trying to achieve :)

 

I'm thankful for any help.

See the Pen bRaZLd by anon (@anon) on CodePen

Link to post
Share on other sites

Okay I don't know if this is the right way to do it, but I solved the problem via a simple function:

 

function pauseLeft() {
    tl.pause();
}

var dummy = document.getElementById('dummy');
    
    tl = new TimelineMax({repeat: -1, paused: true});
    
    tl
        .to(dummy, 0.5, {x: '+=60', ease:Power3.easeOut, onComplete:pauseLeft}, 0.5)
        .to(dummy, 0.5, {x: '-=60', ease:Power3.easeOut, onComplete:pauseLeft}, 1.5);

 

 

Thanks anyway :)

Link to post
Share on other sites

Hi hallibus,

 

Welcome to GreenSock Forums.

 

This could be an alternative:

 

See the Pen BZJXKL by mikeK (@mikeK) on CodePen

Happy tweening ...

 

Link to post
Share on other sites

Thanks for pointing that out. This should be fixed in 1.20.1 (out now). 

  • Like 1
Link to post
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.

×