Capítulo 9 de 411
gsap.context() collects every GSAP animation and ScrollTrigger created inside a function so they can all be reverted or killed together, and optionally scopes selector text to one root element.
gsap.to/from/timeline/... calls made inside it get tracked automatically.ctx.revert(): instantly undoes and removes everything the context collected, restoring original inline styles.gsap.to(".box", ...)) to descendants of that root — useful in React/Angular to avoid manual refs.useGSAP() hook wraps this pattern with automatic cleanup, and is the recommended approach in React instead of calling gsap.context() directly.let ctx = gsap.context(() => {
gsap.to(".box", { x: 100 });
gsap.timeline().to(".a", { opacity: 0 }).to(".b", { opacity: 0 });
});
// later, undo everything created above in one call:
ctx.revert();
useGSAP() React hook over calling gsap.context() by hand in React code.