Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Mr Pablo

How to change a timeline parameter that has already been set?

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

I have a basic timeline where I am setting the X parameter based on the width of a DIV.

 

After the timeline completes, I am changing the DIV content, and the width changes.

 

How would I go about changing what the X parameter is, now that I have changed what it's initial value was.

 

Pseudo-code example:

 

var width;

 

width = $(div).width();

 

timeline =  timeline.fromTo( ($(div), time, { x: 0 }, { x: width } );

 

function ontimelinecomplete {

    $(div).content(new content), width = $(div).newWidth()

}

 

This is what I have currently, but the timeline still uses the original width.

Link to comment
Share on other sites

What if I'm using fromTo?

 

That uses two sets of values and I only need to change the second, "to", value.

 

http://jsfiddle.net/z6urqkpe/

 

You can see here, I am trying to get timeline.vars.css, but it returns undefined.

Link to comment
Share on other sites

for .fromTo() tweens do like this :

var Tween = TweenMax.fromTo(".red",10,{x:0},{x:100});

var tl = new TimelineMax();
tl.add(Tween)
  .to(".blue", 2, {x:100});

$("#change").on("click", function() {
  Tween.vars.startAt.x = 200; // from value
  Tween.vars.css.x = 500; // to value
  tl.seek(0).invalidate().restart();
});
  • Like 1
Link to comment
Share on other sites

Please see my edit above, I cannot access vars.css or vars.startAt either, for my timeline.

Link to comment
Share on other sites

I don't see in your code where you're trying to access the vars.

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