Repeat
Repeat
Repeats animation multiple times.
Example
gsap.to(".box", {
x: 300,
duration: 1,
repeat: 2
});
Timeline
Run 1 Run 2 Run 3
Because:
repeat: 2
means repeat 2 extra times.
Infinite Repeat
repeat: -1
Example:
gsap.to(".box", {
rotation: 360,
duration: 2,
repeat: -1
});
Infinite rotation.
Yoyo
Makes animation reverse direction after each repeat.
Example
gsap.to(".box", {
x: 300,
duration: 1,
repeat: 3,
yoyo: true
});
Without Yoyo
→ reset → reset → reset
With Yoyo
→ ← → ←