Chapter 20: gsap.isTweening()
Core Idea
gsap.isTweening() reports whether a target has an actively running tween — paused, completed, or not-yet-started tweens don't count.
Key Concepts
- Returns: Boolean.
- Target: accepts selector text or a direct object/element reference.
Code Examples
if (!gsap.isTweening("#id")) {
// safe to start a new animation without conflicting with an active one
}
- What it demonstrates: guarding against starting a duplicate/overlapping animation on an element that's already mid-tween.
Key Takeaways
- "Active" specifically excludes paused, completed, and pending (not-yet-started) tweens — only currently-playing counts.
- Common guard before triggering hover/click-driven animations to avoid restarting an in-progress one.
Connects To
- gsap.getTweensOf(): get the actual tween instances instead of just a boolean.