How greensock/gsap works
Purpose and Consumption
GSAP is a zero-dependency, framework-agnostic browser JavaScript animation engine. It interpolates and applies values over time to CSS, SVG, canvas, and arbitrary JavaScript objects. Primary source entry points are src/index.js (core package import) and src/all.js (core plus public plugins); browser-compatible UMD artifacts are published under dist/, notably dist/gsap.js and dist/all.js.
Core Animation Runtime
src/gsap-core.js owns the animation model: tweens, timelines, easing, ticker-driven rendering, overwrite/lifecycle behavior, callbacks, and utility APIs. It is the central control boundary: user calls create animation instances, the ticker advances time, and render passes resolve and update target properties. src/index.js composes this core with the default CSS integration.
Property Rendering Layer
src/CSSPlugin.js translates generic tween properties into browser style/transform updates, handling CSS-specific normalization and rendering. Core-level property tweening delegates to registered plugins when they claim a property or target type. This keeps the timing/sequencing engine in src/gsap-core.js independent from DOM/CSS mechanics.
Plugin Registration and Extensions
Plugins are separately importable modules that integrate through explicit gsap.registerPlugin(...); they extend target parsing, rendering, or interaction/input behavior without requiring the core to depend on them. Aggregated exports in src/all.js expose the standard toolset. Major extension families include:
• Scroll and viewport orchestration: src/ScrollTrigger.js, src/ScrollSmoother.js, src/Observer.js.
• Direct manipulation and inertia: src/Draggable.js, src/InertiaPlugin.js.
• Geometry/path transformations: src/MotionPathPlugin.js, src/MorphSVGPlugin.js, src/Flip.js.
• Content and special-property rendering: src/SplitText.js, src/TextPlugin.js, src/DrawSVGPlugin.js.
Geometry and Motion Utilities
Reusable path, matrix, and velocity primitives support SVG motion, transforms, draggable interaction, and related plugins. src/utils/paths.js handles path-oriented calculations; src/utils/matrix.js provides transform/matrix handling; src/utils/VelocityTracker.js supplies sampled velocity data used by inertia-oriented behavior. src/MotionPathHelper.js adds an authoring/debug interaction layer over motion-path facilities.
Distribution Boundaries
Authoritative implementation is in src/; ES-module deliverables mirror it in esm/, with package-facing entry modules esm/index.js and esm/all.js. dist/ provides UMD files for script-tag, AMD/CommonJS-compatible environments and individually consumable plugin bundles, e.g. dist/ScrollTrigger.js and dist/Draggable.js. TypeScript consumers receive declaration-only API contracts under types/, centered on types/index.d.ts and types/gsap-core.d.ts.
Runtime and External Dependencies
The library targets major web browsers and uses browser facilities such as DOM/CSS, SVG, scrolling, and pointer/touch/wheel events when relevant plugins are enabled. It has no runtime dependencies and no backend or required external service. NPM package imports and CDN-hosted dist/ artifacts are alternative delivery mechanisms; React support mentioned by documentation is supplied by a separate package, not this repository.
Main entry points: all.js All-plugins entry · index.js Core entry · gsap-core.js Animation runtime · MotionPathPlugin.js Motion and geometry
Components 17
Core Runtime
- Core entry · Composes GSAP core with the default CSS integration.
src/index.js - Animation runtime · Owns tweens, timelines, ticker, rendering lifecycle, and utilities.
src/gsap-core.js
Property Rendering
- CSSPlugin · Maps tween properties to browser style and transform updates.
src/CSSPlugin.js
Extensions
- All-plugins entry · Aggregates the standard public plugin toolset.
src/all.js - Scroll extensions · ScrollTrigger, ScrollSmoother, and Observer orchestration.
src/ScrollTrigger.js - Drag and inertia · Direct manipulation backed by velocity-based inertia.
src/Draggable.js - Motion and geometry · Motion paths, SVG morphing, and FLIP transforms.
src/MotionPathPlugin.js - Content renderers · SplitText, TextPlugin, and DrawSVGPlugin.
src/SplitText.js - Motion path helper · Interactive authoring and debugging layer for motion paths.
src/MotionPathHelper.js - Path utilities
src/utils/paths.js - Matrix utilities
src/utils/matrix.js - Velocity tracker · Samples velocity for inertia-oriented behavior.
src/utils/VelocityTracker.js
Package Delivery
- ESM deliverables · Mirrors source for package module consumers.
esm/index.js - UMD bundles · Script-tag, AMD, and CommonJS-compatible artifacts.
dist/gsap.js - Type declarations · Declaration-only public API contracts.
types/index.d.ts
Other components
- Application code · Creates animations and registers optional plugins.
- Browser APIs · DOM, CSS, SVG, scrolling, and input facilities.
Connections 21
- Application code → Core entry: imports core package
- Application code → All-plugins entry: imports standard toolset
- Application code → UMD bundles: loads browser bundle
- Core entry → Animation runtime: exports
- Core entry → CSSPlugin: registers default integration
- All-plugins entry → Core entry: includes core entry
- All-plugins entry → Scroll extensions: exports
- All-plugins entry → Drag and inertia: exports
- All-plugins entry → Motion and geometry: exports
- All-plugins entry → Content renderers: exports
- Animation runtime → CSSPlugin: delegates claimed properties
- Animation runtime → Browser APIs: renders through
- Scroll extensions → Browser APIs: uses scroll and input
- Drag and inertia → Velocity tracker: uses
- Drag and inertia → Matrix utilities: uses transforms
- Motion and geometry → Path utilities: uses path calculations
- Motion and geometry → Matrix utilities: uses transforms
- Motion path helper → Motion and geometry: authors and debugs
- ESM deliverables → Core entry: mirrors
- UMD bundles → Core entry: bundles
- Type declarations → Animation runtime: declares API for