What's changed
🩹 Bug fix — useGsap() premature context revert during page transitions
The composable used onScopeDispose to guard GSAP context cleanup. In certain Nuxt
configurations (async pages wrapped in <Suspense>), onScopeDispose can fire
synchronously before onBeforeRouteLeave sets the internal isLeavingViaRoute flag,
causing the context to revert immediately on unmount instead of waiting for
page:transition:finish. Animations would stop (and DOM properties snap back) as
soon as the user navigated away — before the page leave transition finished.
Fix: replaced onScopeDispose with onUnmounted, which fires asynchronously
in the next render flush and is always guaranteed to run after navigation guards.
This is the same behavior that the (now-deprecated)
cleanupOn: 'route-leave'option
was originally introduced to provide. The deprecation notice remains, since after this
fix both values produce identical behavior.
🏡 Playground improvements
- New demo:
useGsap (timeline)— finite 8-second timeline with progress bar,
useful for visually verifying that the cleanup timing is correct during page transitions - Fixed
scroll-triggerdemo:animation.kill()does not kill associated ScrollTrigger
instances — addedanimation.scrollTrigger?.kill()before killing the tween - Fixed
draggableandflipdemos: added null guards before accessing component refs