Duration, Delay, and Repeat
What You'll Learn
You'll learn how to control the timing, pacing, and repetition of GSAP animations using core properties that make your animations wait, last longer, or loop.
The Core Timing Controls
When you animate with gsap.to(), gsap.from(), or gsap.fromTo(), you're not just setting what changes—you're also controlling when and how often it happens. GSAP gives you precise timing control through these essential properties:
Duration
The duration property sets how long your animation takes to complete, measured in seconds:
gsap.to(".box", {
x: 200,
duration: 2 // Takes 2 seconds to move
});
Default: 0.5 seconds if you don't specify it.
Delay
The delay property makes your animation wait before starting:
gsap.to(".box", {
x: 200,
duration: 1,
delay: 0.5 // Waits half a second before animating
});
Think of it like a countdown timer before the animation begins.
Repeat
The repeat property controls how many extra times the animation runs after the first time:
gsap.to(".box", {
rotation: 360,
duration: 1,
repeat: 2 // Plays once + repeats twice = 3 total
});
Use repeat: -1 for infinite looping.
RepeatDelay
The repeatDelay property adds a pause between each repeat cycle:
gsap.to(".box", {
x: 200,
duration: 1,
repeat: 3,
repeatDelay: 0.5 // Half-second pause between each repeat
});
This creates a rhythmic pattern: animate → pause → animate → pause.
Key Takeaway: Duration controls speed, delay controls when to start, repeat controls how many times, and repeatDelay adds breathing room between cycles—together they give you complete control over animation timing and rhythm.