Jump to content
Search Community

TimelineLite: How to set seek() duration or easing?

acidking 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

You can use TimelineMax.tweenTo() for this

 

Here is a demo:

http://codepen.io/GreenSock/pen/aiGJB

 

Note you can apply custom easing to each tweenTo()

 

var tl = new TimelineMax({paused:true});


tl.to("#box", 1, {left:200, ease:Linear.easeNone}, "label0")
  .to("#box", 1, {top:200, ease:Linear.easeNone}, "label1") 
  .add("label2")


$("#label2").on("click", function() {
  tl.tweenTo("label2", {ease:Bounce.easeOut});
})

  • Like 1
Link to comment
Share on other sites

Sure you can use the timeScale() method to change how fast the animation happens, and since the tweenTo method accepts callbacks you can insert an onComplete call to restore the timeScale back to 1 (which means normal speed), this is from Carl's code:

var tl = new TimelineMax({paused:true});

tl.to("#box", 1, {left:200, ease:Linear.easeNone}, "label0")
  .to("#box", 1, {top:200, ease:Linear.easeNone}, "label1") 
  .add("label2")

$("#label0").on("click", function() {
  tl.timeScale(1);
  tl.tweenTo("label0");
})

$("#label1").on("click", function() {
  tl.timeScale(0.25)
  tl.tweenTo("label1", {ease:Back.easeOut, onComplete:resetTimeScale});
})

$("#label2").on("click", function() {
  tl.timeScale(1.5);
  tl.tweenTo("label2", {ease:Bounce.easeOut, onComplete:resetTimeScale});
})

function resetTimeScale()
{
  tl.timeScale(1);
}

Like that when you click on "label1" the animation will go slower than normal speed. If you click on "label2" it'll go faster and if you click on "label0" it'll go at normal speed.

 

Here's the API reference regarding timeScale:

http://api.greensock.com/js/com/greensock/core/Animation.html#timeScale()

 

Rodrigo.

  • 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...