gsap.globalTimeline()
Type : Timeline
gsap.globalTimeline
is the root Timeline instance that drives everything in GSAP, making it a powerful way to affect all animations at once. Keep in mind, however, that gsap.delayedCalls() are also technically tweens, so if you pause() or timeScale() the globalTimeline, it will affect delayedCalls() too. If you want to omit those, check out gsap.exportRoot().
Useful Methods
gsap.globalTimeline
.pause()
- Pauses the global timeline which affects ALL animations. Returns itself.gsap.globalTimeline
.play()
- Resumes the global timeline which affects ALL animations. Returns itself.gsap.globalTimeline
.paused()
- Returnstrue
if the global timeline is paused. Returnsfalse
if the global timeline is playing.gsap.globalTimeline
.timeScale()
- Gets or sets the global time scale which is a multiplier that affects ALL animations. This doesn't actually set thetimeScale()
of each individual tween/timeline, but rather it affects the rate at which the root timeline plays (that timeline contains all other animations). This is a great way to globally speed up or slow down all animations at once. For example:
gsap.globalTimeline.timeScale(0.5); //plays at half-speed
gsap.globalTimeline.timeScale(2); //plays twice the normal speed
var currentTimeScale = gsap.globalTimeline.timeScale(); //returns the current global timeScale
Notes
- Keep in mind that since the global timeline is used to run all other tweens and timelines,
gsap.globalTimeline.isActive()
will always returntrue
regardless of whether or not there are any tweens or timelines currently active.