Tween Intro
- A Tween in GSAP (GreenSock Animation Platform) is a single animation that transitions (animates) from one set of values to another over a specific duration.
TWEEN
A Tween is the core engine behind GSAP animations — you can think of it as a powerful property updater. You provide it with target elements, a duration, and the properties you want to animate. As the tween’s playhead progresses over time, GSAP automatically calculates the correct intermediate values and applies them smoothly to the target.
You can create a Tween using any of the following methods (each returns a Tween instance):
-
gsap.to() -
gsap.from() -
gsap.fromTo()
-
For straightforward animations, these methods are usually all you’ll need. For example:
gsap.to(".box", {
x: 200,
duration: 1
});
Because GSAP can animate any numeric property of any JavaScript object, you’re not limited to just CSS styles or DOM elements. Feel free to experiment — you’ll be surprised by how many things GSAP can animate effortlessly.
While you can create simple animation sequences using the
delayproperty, complex choreography becomes much easier with Timelines. A Timeline acts like a container that holds multiple Tweens (and even other Timelines), allowing you to control their timing and behavior together as one unit. This makes advanced sequencing clean, organized, and flexible. Check the Timeline documentation for more details.If you need to control a Tween later (pause, resume, reverse, etc.), simply store it in a variable. GSAP’s object-oriented approach makes this convenient and intuitive.
GSAP Special Properties
Property Description callbackScope Defines the scope/context used for callback functions. data Attaches custom data to the tween for referencing later. delay Time to wait before the animation begins (in seconds). duration Total length of the animation (in seconds). Default: 0.5. ease Controls the motion curve/easing style of the animation. Default: "power1.out". id Assigns a unique identifier to the tween so it can be found later. immediateRender Forces the tween to render immediately upon creation rather than waiting for the next frame. inherit Determines if the tween should inherit defaults from its parent timeline. lazy Optimizes performance by batching DOM reads/writes during the first render. onComplete Callback triggered when the animation finishes. onCompleteParams Parameters passed to the onComplete callback. onRepeat Callback triggered every time the animation repeats. onRepeatParams Parameters passed to the onRepeat callback. onReverseComplete Callback triggered when the animation fully completes in reverse. onReverseCompleteParams Parameters passed to the onReverseComplete callback. onStart Callback triggered when the animation first starts. onStartParams Parameters passed to the onStart callback. onUpdate Callback triggered every time the animation updates per frame. onUpdateParams Parameters passed to the onUpdate callback. overwrite Controls conflict handling with other tweens targeting the same properties. paused Determines if the animation starts in a paused state. repeat Number of times the animation should repeat. -1means infinite repeats.repeatDelay Delay time between repeated animation cycles. repeatRefresh Refreshes starting/ending values on each repeat (useful for dynamic/random values). reversed Starts the tween with its playhead reversed. runBackwards Swaps starting and ending values internally (reverse motion). stagger Delays the start time between multiple targets being animated. startAt Sets initial values before the tween begins animating. yoyo Causes the tween to reverse direction on every alternate repeat. yoyoEase Applies a different easing during the yoyo (reverse) phase. keyframes Allows the targets to animate through multiple sequential states.
GSAP Extra Capabilities
Plugins
Concept Description Plugins Optional add-ons that extend GSAP’s core functionality. Rendering Integration Some plugins simplify working with rendering libraries like PIXI.js or EaselJS. Advanced Effects Plugins enable features like SVG morphing, draggable components, etc. Lightweight Core GSAP stays small by keeping advanced features optional. Modular Usage Only load the plugins you need for performance efficiency. Plugin List A full list is available in GSAP documentation.