Capítulo 10 de 411

Chapter 10: gsap.defaults()

Core Idea

gsap.defaults() sets tween-specific properties (like ease and duration) that every subsequently created tween inherits unless it explicitly overrides them or sets inherit: false.

Key Concepts

  • Tween-specific vs. engine config: defaults() is for properties every tween can have (ease, duration, etc); non-tween-specific settings (units, autoSleep, force3D) belong in gsap.config() instead.
  • Override: any individual tween can still specify its own value to override the default.

Code Examples

gsap.defaults({
  ease: "power2.in",
  duration: 1,
});
  • What it demonstrates: changing the baseline ease/duration for every tween created afterward, without repeating it on each call.

Key Takeaways

  1. Use defaults() for animation-affecting values you want inherited; use config() for engine-level behavior.
  2. A tween's own explicit value always wins over the global default.

Connects To

  • gsap.config(): the counterpart for non-tween-specific, engine-level settings.