Jump to content
GreenSock

TweenMax

.updateTo()

.updateTo( vars:object, resetDuration:Boolean ) : *

Updates tweening values on the fly so that they appear to seamlessly change course even if the tween is in-progress.

Parameters

vars: object

Object containing properties with the destination values that should be udpated. You do NOT need to redefine all of the original vars values – only the ones that should be updated (although if you change a plugin value, you will need to fully define it). For example, to update the destination x value to 300 and the destination y value to 500, pass: {x:300, y:500}.

resetDuration: Boolean

(default = false) — If the tween has already started (or finished) and resetDuration is true, the tween will restart. If resetDuration is false, the tween’s timing will be honored (no restart) and each tweening property’s starting value will be adjusted so that it appears to seamlessly redirect to the new destination value.

Returns : *

self (makes chaining easier)

Details

Updates tweening values on the fly so that they appear to seamlessly change course even if the tween is in-progress. Think of it like dynamically updating the vars object that was passed in to the tween when it was originally created. You do NOT need to redefine all of the vars properties/values - only the ones that you want to update. You can even define new properties that you didn't define in the original vars object.

If the resetDuration parameter is true and the tween has already started (or finished), updateTo() will restart the tween. Otherwise, the tween's timing will be honored. And if resetDuration is false and the tween is in-progress, the starting values of each property will be adjusted so that the tween appears to seamlessly redirect to the new destination values. This is typically not advisable if you plan to reverse the tween later on or jump to a previous point because the starting values would have been adjusted.

updateTo() is only meant for non-plugin values. It's much more complicated to dynamically update values that are being handled inside plugins - that is not what this method is intended to do.

//a generic JavaScript object (not a DOM element)
var obj = {x:0, y:0, age:18, weight:180}

//create a tween that modifies properties of obj
var tween = new TweenMax(obj, 2, {x:100, y:200, age:40, weight:250});
//then later, update the destination x and y values, restarting the tween
tween.updateTo({x:300, y:0}, true);
//or to update the values mid-tween without restarting, do this:
tween.updateTo({x:300, y:0}, false);
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×