Capítulo 51 de 411

Chapter 51: Timeline.fromTo()

Core Idea

fromTo() inserts a .fromTo()-style tween into the timeline — shorthand for add(gsap.fromTo(...)).

Reference Tables

ParameterTypeDescription
targetObject | Array | Stringtarget(s) or selector text
fromVarsObjectstarting values only (no special props like duration/ease here)
toVarsObjectending values + special props
positionNumber | Stringwhere in the timeline

Code Examples

tl.fromTo(".box", { opacity: 0 }, { opacity: 1, duration: 1 });

Anti-patterns

  • Putting duration/ease/delay in fromVars: those special properties belong only in toVars.

Connects To

  • Timeline.from() / to(): the other tween-insertion shortcuts.