Share Posted December 2, 2015 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 More sharing options...
Share Posted December 2, 2015 Hi Mr Pablo you need to use .invalidate() method : http://greensock.com/docs/#/HTML5/GSAP/TimelineMax/invalidate/ pls check this out : See the Pen bddvgy by MAW (@MAW) on CodePen 1 Link to comment Share on other sites More sharing options...
Author Share Posted December 2, 2015 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 More sharing options...
Share Posted December 2, 2015 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(); }); 1 Link to comment Share on other sites More sharing options...
Author Share Posted December 2, 2015 Please see my edit above, I cannot access vars.css or vars.startAt either, for my timeline. Link to comment Share on other sites More sharing options...
Author Share Posted December 3, 2015 Bump Link to comment Share on other sites More sharing options...
Share Posted December 3, 2015 I don't see in your code where you're trying to access the vars. Link to comment Share on other sites More sharing options...
Author Share Posted December 3, 2015 Crap, the jsfiddle didn't save, I have fixed it. http://jsfiddle.net/z6urqkpe/4/ towards the bottom, in the changeFeedContent function, I get undefined for timeline.vars.startAt and css Link to comment Share on other sites More sharing options...
Share Posted December 3, 2015 You are trying to read properties of the timeline that don't exist. But why don't you just clear the timeline and start over. http://jsfiddle.net/OSUblake/od03q8yL/ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now