Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hetari/creative-coding/llms.txt
Use this file to discover all available pages before exploring further.
useGsap is the single entry point for all GSAP animation work across the creative-coding workspace. It returns the gsap instance with ScrollTrigger already registered, a useGsapContext helper for scoped animations that auto-revert on teardown, and a lazyLoadPlugin function for loading the rest of the GSAP plugin catalogue on demand. A set of gsap.utils functions is also re-exported as named exports so you can import them directly from the composable file without referencing gsap.utils yourself.
Signature
Return Value
The GSAP instance with
ScrollTrigger pre-registered. Use gsap.to(), gsap.from(), gsap.set(), gsap.timeline(), gsap.matchMedia(), gsap.quickTo(), and all other core GSAP methods directly on this object.The
ScrollTrigger plugin class, already registered with the GSAP instance at module load time. Pass it directly to scrollTrigger: option objects inside tweens, or call ScrollTrigger.create(), ScrollTrigger.refresh(), etc.Dynamically imports and registers a GSAP plugin the first time it is requested. Subsequent calls for the same plugin name are no-ops — the module-level
registered set prevents double-registration. Returns the plugin class itself so you can use it immediately after await.useGsapContext
(scope: Ref<HTMLElement | null | undefined>, fn: (self: gsap.Context) => void) => gsap.Context | undefined
Creates a
gsap.context() bound to the element held by scope. All GSAP selector strings inside fn (e.g. gsap.from('.item', …)) are scoped to that element rather than the full document. The context is automatically reverted — killing all tweens, ScrollTriggers, and inline style resets — when the Vue scope is disposed, via tryOnScopeDispose.Exported Utility Functions
The following functions are re-exported directly fromgsap.utils as named exports. Import any of them straight from @/composables/useGsap without going through the gsap object:
clamp · mapRange · normalize · snap · toArray · interpolate · pipe · wrap · wrapYoyo · distribute · random · shuffle · getUnit · unitize · splitColor · selector
Lazy Plugin Names
The following GSAP plugins are available tolazyLoadPlugin. Each is code-split and only downloaded when you call lazyLoadPlugin with its name:
| Plugin name | Description |
|---|---|
CustomEase | Define custom SVG-path-based easing curves |
Draggable | Drag-and-drop with physics boundaries |
Flip | Seamless layout-to-layout state transitions |
MotionPathPlugin | Animate elements along SVG paths |
Observer | Unified scroll, drag, pointer, and wheel observation |
ScrollToPlugin | Smooth programmatic scroll-to-position |
TextPlugin | Character-by-character text replacement tweens |
EasePack | Extended easing functions (e.g. SlowMo, RoughEase) |
ScrollTrigger is registered at module load time — you never need to call lazyLoadPlugin('ScrollTrigger').Usage Example
The following pattern is taken from theascii-hand sketch, which uses useGsapContext to create a scroll-driven ASCII curtain reveal and staggered text animation:
ScrollTrigger instances created inside the useGsapContext callback are automatically reverted when the component’s Vue scope is disposed — no manual ctx.revert() call needed.