Jump to content
Search Community

Stop Tween and resume after pause?

AlexMfyb test
Moderator Tag

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,

 

I am new to GSAP (and my English is bad, sorry).

 

Is there any way how to stop tween on defined point (for example on progress = 0.5), pause it for few seconds and then resume playing?

 

For example, I have this tween:

 

var tw = TweenMax.to($("#myID"), 1, {top:0} );

 

I need this tween stop after 0.5 seconds (this is middle of the tween) for 10 seconds and after this pause resume playing.

 

Thanks

 

Alex

Link to comment
Share on other sites

A timeline would be perfect for this:

var tw = new TimelineLite();
    tw.to("myID", 1, { top:100 })
      .addPause(0.5, resumeTimeline, [10]);


function resumeTimeline(seconds) {
    TweenLite.delayedCall(seconds, this.resume, null, this);
}
or even

var tw = new TimelineLite();
    tw.to("myID", 1, {top:100} )
      .addPause(0.5, TweenLite.delayedCall, [10, tw.resume, null, tw]);
  • Like 2
Link to comment
Share on other sites

I usually prefer timelines for this too, as Jamie suggested, but another option would be to use delayedCalls:

var tween = TweenLite.to("#myID", 1, {top:100});

TweenLite.delayedCall(0.5, function() {
    tween.pause();
    TweenLite.delayedCall(10, function() {
        tween.resume();
    });
});

There are several other ways to do it too, but I don't want to confuse things :) 

  • 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.
×
×
  • Create New...