TweenMax instance
GreenSock Docs
TweenMax.to()
[static] Static method for creating a TweenMax instance that animates to the specified destination values (from the current values).
Parameters
target: Object
Target object (or array of objects) whose properties should be affected. When animating DOM elements, the target can be: a single element, an array of elements, a jQuery object (or similar), or a CSS selector string like “#feature” or “h2.author”. GSAP will pass selector strings to a selector engine like jQuery or Sizzle (if one is detected or defined through TweenLite.selector), falling back to document.querySelectorAll().
duration: Number
Duration in seconds (or frames if useFrames:true
is set in the vars
parameter)
vars: Object
An object defining the end value for each property that should be tweened as well as any special properties likeonComplete
, ease
, etc. For example, to tween obj.x
to 100 and obj.y
to 200 and then call myFunction
, do this:TweenMax.to(obj, 1, {x:100, y:200, onComplete:myFunction});
Show More
Returns : TweenMax

Details
Static method for creating a TweenMax instance that animates to the specified destination values (from the current values). This static method can be more intuitive for some developers and shields them from potential garbage collection issues that could arise when assigning a tween instance to a persistent variable. The following lines of code produce identical results:
TweenMax.to(obj, 1, {x:100});
var myTween = new TweenMax(obj, 1, {x:100});
var myTween = TweenMax.to(obj, 1, {x:100});
Each line above will tween the "x"
property of the mc
object to a value of 100 over the coarse of 1 second. They each use a slightly different syntax, all of which are valid. If you don't need to store a reference of the tween, just use the static TweenMax.to( )
call.
Since the target
parameter can also be an array of objects, the following code will tween the x property of obj1, obj2, and obj3 to a value of 100 simultaneously:
TweenMax.to([obj1, obj2, obj3], 1, {x:100});
Even though 3 objects are animating, there is still only one tween created. In order to stagger or offset the start times of each object animating, please see the TweenMax.staggerTo()
method (TimelineLite has one too).
For simple sequencing, you can use the delay
special property (like TweenMax.to(obj, 1, {x:100, delay:0.5})
), but it is highly recommended that you consider using TimelineLite (or TimelineMax) for all but the simplest sequencing tasks. It has an identical to()
method that allows you to append tweens one-after-the-other and then control the entire sequence as a whole. You can even have the tweens overlap as much as you want.