Timeline Position Parameter
You'll learn how to precisely control when animations start within a GSAP timeline using relative and absolute positioning.
Core Concept
When you create a GSAP timeline (which you now know from "GSAP Timelines Basics"), animations queue up one after another by default. But the position parameter lets you break free from that sequence—you can insert animations at specific moments, overlap them, or create gaps.
Think of a timeline like a music track with multiple instruments. Without position parameters, each instrument waits for the previous one to finish. With position parameters, you can make them all start together, or have the drums kick in 2 seconds early while the bass is still playing.
How It Works
The position parameter is an optional argument you pass when adding animations to a timeline:
const tl = gsap.timeline();
// Default: starts after previous animation ends
tl.to(".box1", { x: 100, duration: 1 });
// Absolute: starts at exactly 2 seconds into timeline
tl.to(".box2", { x: 100, duration: 1 }, 2);
// Relative: starts 0.5 seconds BEFORE previous ends
tl.to(".box3", { x: 100, duration: 1 }, "-=0.5");
// Relative: starts 0.3 seconds AFTER previous ends
tl.to(".box4", { x: 100, duration: 1 }, "+=0.3");
// At the start of the timeline
tl.to(".box5", { x: 100, duration: 1 }, 0);
// Same time as previous animation
tl.to(".box6", { x: 100, duration: 1 }, "<");
Use absolute numbers for precise timing, "+="/"-=" for relative offsets, 0 for the start, and "<" to sync with the previous animation's start.
Key Takeaway: The position parameter gives you surgical control over animation timing within timelines, letting you create complex, overlapping sequences instead of just linear chains.