In the Skill's Own Terms
Official GSAP guidance for animating Vue, Nuxt, Svelte and SvelteKit components, where the framework lifecycle decides when DOM nodes exist. It tells the agent to create tweens and ScrollTriggers only after mount — onMounted in Vue, onMount in Svelte — inside gsap.context(scope) with the container ref passed as the second argument, so selectors like .box stay inside that component.
On unmount, ctx.revert() kills the animations and ScrollTriggers and reverts inline styles. It also covers a Nuxt 4 useGSAP composable that registers ScrollTrigger once and lazy loads plugins such as SplitText by dynamic import, plus refreshing trigger positions after layout changes.
What it produces
- Framework-specific animation code or review changes that create GSAP work after mount and revert it on unmount.
- Scoped component selectors and ScrollTrigger cleanup, following the repository's Vue and Svelte examples.
- A Nuxt composable for shared plugin registration and optional lazy loading when the project needs it.
How It Works
- 01Wait for the DOM Before Creating
Tweens and ScrollTriggers are only created once the component's DOM is available, using onMounted in Vue or onMount in Svelte so the container ref actually exists.
- 02Scope Everything to the Component Root
The whole animation setup is wrapped in gsap.context(callback, scope), with the container ref passed as the second argument so selectors such as .item resolve inside that subtree only.
- 03Revert in the Framework Teardown
Each example keeps the context in a variable and calls ctx.revert() from onUnmounted (Vue) or from the cleanup function returned by onMount (Svelte).
- 04Refresh After Layout Changes
ScrollTrigger positions are recalculated once the layout settles, for example after data loads change trigger positions.