Jump to content

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

TweenMax.fromTo set vars

Recommended Posts

Having issues with  tween.fromVars = {}, tween.toVars = {}

Link to post
Share on other sites



For optimization reasons what you're trying to do is not possible. Basically when you create a GSAP instance the starting and end values of the properties being tweened are recorded in order to avoid continous read/write operations.


What I do when I face this type of scenarios is to create a function to create the fromTo instance again and use the instance's current progress to avoid restarting it, like this:

var tween = TweenMax.fromTo(element, time, {/*fromVars*/}, {/*toVars*/});

// the function, just pass the config object as arguments
function createTween(fromVars, toVars) {

  var currentProgress = tween.progress();


  tween = TweenMax.fromTo(element, time, {fromVars}, {toVars}).progress(currentProgress);

// later on your code call the function
createTween({x:0, y:0, rotationX:0},{x:100, y:100, rotationX:180});

Give that a try and let us know if you need anything else.



  • Like 3
Link to post
Share on other sites

Thanks Rodrigo. 


Your method also solves it.

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.