GSAPPlugin
Defined in: plugins/GSAPPlugin.ts:312
High-performance GSAP animation plugin for PIXI.js applications.
Integrates the GreenSock Animation Platform (GSAP) into the application framework, providing powerful and flexible animation capabilities with optimized PIXI.js integration. Features custom animation context management for grouped animation control, custom easing registration, and automatic PIXI.js property animation support.
Key Features:
- Full GSAP integration with PIXI.js optimization
- Custom animation contexts for grouped control (pause/play/kill by category)
- Custom easing function registration and management
- Automatic PIXI filter integration (BlurFilter, ColorMatrixFilter)
- Memory-efficient animation tracking and cleanup
- Global and context-specific animation management
Important: Animation “contexts” in this plugin are custom collections (Sets) for grouping
animations and are NOT the same as gsap.Context
objects provided by GSAP itself.
Example
Section titled “Example”// Basic setup and usageconst gsapPlugin = app.plugins.get<IGSAPPlugin>('GSAPPlugin');
// Create optimized PIXI animationsconst sprite = new PIXI.Sprite(texture);gsapPlugin.anim.to(sprite, { x: 100, y: 50, alpha: 0.8, duration: 1, ease: 'back.out(1.7)'});
// Register custom eases for game feelgsapPlugin.registerCustomEase('gameJuice', (t) => { return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;});
// Context-based animation managementconst menuTween = gsapPlugin.anim.to(menuButton, { scale: 1.1, duration: 0.3 });gsapPlugin.addAnimation(menuTween, 'menuAnimations');
// Later: pause all menu animations when game startsgsapPlugin.pauseAll('menuAnimations');
// Animate PIXI filtersconst blurFilter = new PIXI.BlurFilter();sprite.filters = [blurFilter];gsapPlugin.anim.to(blurFilter, { blur: 10, duration: 2 });
Remarks
Section titled “Remarks”- Automatically registers PixiPlugin for optimized PIXI.js property animations
- Includes ColorMatrixFilter and BlurFilter integration for advanced effects
- Uses efficient Set-based tracking for O(1) animation context operations
- Provides both global and context-specific animation lifecycle management
- Custom eases are automatically registered with GSAP and stored for reference
Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GSAPPlugin(
id
):GSAPPlugin
Defined in: plugins/Plugin.ts:48
Parameters
Section titled “Parameters”string
= 'Plugin'
Returns
Section titled “Returns”GSAPPlugin
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”__dill_pixel_method_binding_root
Section titled “__dill_pixel_method_binding_root”__dill_pixel_method_binding_root:
boolean
Defined in: plugins/Plugin.ts:39
Inherited from
Section titled “Inherited from”Plugin
.__dill_pixel_method_binding_root
readonly
id:"GSAPPlugin"
='GSAPPlugin'
Defined in: plugins/GSAPPlugin.ts:317
Plugin identifier for framework registration
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get anim(): typeof
gsap
Defined in: plugins/GSAPPlugin.ts:450
Gets the GSAP instance for creating animations. Provides access to the full GSAP API with PIXI.js optimizations enabled.
Returns
Section titled “Returns”typeof gsap
The GSAP instance for creating animations.
Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get app():
A
Defined in: plugins/Plugin.ts:53
Returns
Section titled “Returns”A
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”easeNames
Section titled “easeNames”Get Signature
Section titled “Get Signature”get easeNames():
string
[]
Defined in: plugins/GSAPPlugin.ts:329
Array of all registered custom ease names.
Returns
Section titled “Returns”string
[]
Array of all registered custom ease names.
Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get eases():
Ease
Defined in: plugins/GSAPPlugin.ts:337
Object containing all registered custom eases.
Returns
Section titled “Returns”Object containing all registered custom eases, where keys are ease names and values are GSAP ease functions.
Implementation of
Section titled “Implementation of”options
Section titled “options”Get Signature
Section titled “Get Signature”get options():
O
Defined in: plugins/Plugin.ts:44
Returns
Section titled “Returns”O
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addAnimation()
Section titled “addAnimation()”addAnimation(
animation
,contextId
):Timeline
|Tween
| (Timeline
|Tween
)[]
Defined in: plugins/GSAPPlugin.ts:477
Adds animation(s) to a specified context for grouped management. Creates the context if it doesn’t exist. Defaults to global context if no contextId provided.
Parameters
Section titled “Parameters”animation
Section titled “animation”Single animation or array of animations to track
Timeline
| Tween
| (Timeline
| Tween
)[]
contextId
Section titled “contextId”string
= GSAPPlugin.GLOBAL_CONTEXT_ID
Context identifier (defaults to global context)
Returns
Section titled “Returns”Timeline
| Tween
| (Timeline
| Tween
)[]
The same animation(s) passed in for chaining
Example
Section titled “Example”// Add to specific context for scene managementconst levelTweens = [ gsap.to(player, { x: 100, duration: 2 }), gsap.to(enemy, { rotation: Math.PI, duration: 1.5 }), gsap.to(powerup, { scale: 1.2, yoyo: true, repeat: -1, duration: 0.8 })];gsapPlugin.addAnimation(levelTweens, 'level1Gameplay');
// Add to global context (default)const bgTween = gsap.to(background, { alpha: 0.8, duration: 3 });gsapPlugin.addAnimation(bgTween);
Implementation of
Section titled “Implementation of”addSignalConnection()
Section titled “addSignalConnection()”addSignalConnection(…
args
):void
Defined in: plugins/Plugin.ts:79
Add signal connections to the container.
Parameters
Section titled “Parameters”…SignalConnection
[]
The signal connections to add.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IGSAPPlugin
.addSignalConnection
Inherited from
Section titled “Inherited from”clear()
Section titled “clear()”clear(
contextId
,kill
):void
Defined in: plugins/GSAPPlugin.ts:662
Clears (removes) a specific animation context from tracking. Optionally kills the animations before clearing the context.
Parameters
Section titled “Parameters”contextId
Section titled “contextId”string
The context identifier to clear
boolean
= false
Whether to kill animations before clearing (default: false)
Returns
Section titled “Returns”void
Example
Section titled “Example”// Clear completed level contextgsapPlugin.clear('level1Animations');
// Clear and kill animations simultaneouslygsapPlugin.clear('temporaryEffects', true);
Implementation of
Section titled “Implementation of”clearAll()
Section titled “clearAll()”clearAll(
kill
):void
Defined in: plugins/GSAPPlugin.ts:684
Clears all animation contexts and recreates the global context. Optionally kills all animations before clearing contexts.
Parameters
Section titled “Parameters”boolean
= false
Whether to kill all animations before clearing (default: false)
Returns
Section titled “Returns”void
Example
Section titled “Example”// Complete reset for new gamegsapPlugin.clearAll(true);
// Clear tracking without killing animationsgsapPlugin.clearAll(false);
Implementation of
Section titled “Implementation of”clearGlobal()
Section titled “clearGlobal()”clearGlobal(
kill
):void
Defined in: plugins/GSAPPlugin.ts:750
Clears all animations from the global animation context. Optionally kills the animations before clearing from tracking.
Parameters
Section titled “Parameters”boolean
= false
Whether to kill animations before clearing (default: false)
Returns
Section titled “Returns”void
Example
Section titled “Example”// Clear global context without killinggsapPlugin.clearGlobal();
// Clear and kill global animationsgsapPlugin.clearGlobal(true);
Implementation of
Section titled “Implementation of”clearSignalConnections()
Section titled “clearSignalConnections()”clearSignalConnections():
void
Defined in: plugins/Plugin.ts:85
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IGSAPPlugin
.clearSignalConnections
Inherited from
Section titled “Inherited from”destroy()
Section titled “destroy()”destroy():
void
Defined in: plugins/Plugin.ts:57
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”getContext()
Section titled “getContext()”getContext(
contextId
):null
|AnimationContext
Defined in: plugins/GSAPPlugin.ts:516
Retrieves a custom animation context by its identifier. Returns null if the context doesn’t exist.
Parameters
Section titled “Parameters”contextId
Section titled “contextId”string
The context identifier to look up
Returns
Section titled “Returns”null
| AnimationContext
The animation context Set or null if not found
Example
Section titled “Example”// Check if context exists and get infoconst gameplayContext = gsapPlugin.getContext('gameplayAnimations');if (gameplayContext) { console.log(`Found ${gameplayContext.size} gameplay animations`);
// Iterate through animations if needed gameplayContext.forEach(animation => { console.log('Animation progress:', animation.progress()); });}
Implementation of
Section titled “Implementation of”initialize()
Section titled “initialize()”initialize(
_
,app
):Promise
<void
>
Defined in: plugins/GSAPPlugin.ts:362
Initializes the GSAP plugin with PIXI.js integration and custom configurations. Sets up PixiPlugin, registers custom eases, and creates the global animation context.
Parameters
Section titled “Parameters”any
Plugin options (currently unused, relies on app.config.gsap)
The application instance providing configuration
Returns
Section titled “Returns”Promise
<void
>
Example
Section titled “Example”// Plugin is automatically initialized by the framework// Configuration comes from app.config.gsapconst config = { gsap: { eases: { 'customBounce': (t) => t * t * (3 - 2 * t), 'gameEase': (t) => Math.pow(t, 2.5) } }};
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”killAll()
Section titled “killAll()”killAll(
contextId?
):void
Defined in: plugins/GSAPPlugin.ts:603
Kills (stops and removes) all animations in the specified context or all contexts. Killed animations cannot be resumed and are removed from tracking. If killing all contexts, the global context is automatically recreated.
Parameters
Section titled “Parameters”contextId?
Section titled “contextId?”string
Optional context identifier. If omitted, kills all animations in all contexts
Returns
Section titled “Returns”void
Example
Section titled “Example”// Kill animations when transitioning scenesgsapPlugin.killAll('currentSceneAnimations');
// Emergency stop all animationsgsapPlugin.killAll();
// Clean up specific context before recreationgsapPlugin.killAll('temporaryEffects');
Implementation of
Section titled “Implementation of”killGlobal()
Section titled “killGlobal()”killGlobal():
void
Defined in: plugins/GSAPPlugin.ts:706
Kills all animations within the global animation context only. This affects only animations added to the global context, not other custom contexts.
Returns
Section titled “Returns”void
Example
Section titled “Example”// Kill only global animations, preserve context-specific onesgsapPlugin.killGlobal();
// Useful for clearing background animations while keeping UI animationsgsapPlugin.killGlobal();gsapPlugin.playAll('uiAnimations'); // UI animations continue
Implementation of
Section titled “Implementation of”pauseAll()
Section titled “pauseAll()”pauseAll(
contextId?
):void
Defined in: plugins/GSAPPlugin.ts:576
Pauses all animations in the specified context or all contexts. Animations retain their current progress and can be resumed with playAll().
Parameters
Section titled “Parameters”contextId?
Section titled “contextId?”string
Optional context identifier. If omitted, pauses all animations in all contexts
Returns
Section titled “Returns”void
Example
Section titled “Example”// Pause game animations when menu opensgsapPlugin.pauseAll('gameplayAnimations');
// Pause everything when app loses focuswindow.addEventListener('blur', () => { gsapPlugin.pauseAll();});
// Conditional pausingif (gameState === 'paused') { gsapPlugin.pauseAll('gameplayAnimations');}
Implementation of
Section titled “Implementation of”playAll()
Section titled “playAll()”playAll(
contextId?
):void
Defined in: plugins/GSAPPlugin.ts:540
Plays all animations in the specified context or all contexts. Useful for resuming paused animations or ensuring all animations are active.
Parameters
Section titled “Parameters”contextId?
Section titled “contextId?”string
Optional context identifier. If omitted, plays all animations in all contexts
Returns
Section titled “Returns”void
Example
Section titled “Example”// Resume specific context after pausegsapPlugin.playAll('menuAnimations');
// Resume all animations (e.g., after app regains focus)gsapPlugin.playAll();
// Conditional playbackif (gameState === 'playing') { gsapPlugin.playAll('gameplayAnimations');}
Implementation of
Section titled “Implementation of”postInitialize()
Section titled “postInitialize()”postInitialize(
_app
):void
|Promise
<void
>
Defined in: plugins/Plugin.ts:68
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
| Promise
<void
>
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”registerCustomEase()
Section titled “registerCustomEase()”registerCustomEase(
name
,ease
):Ease
Defined in: plugins/GSAPPlugin.ts:410
Registers a single custom ease function with GSAP. The ease becomes available for use in all GSAP animations by name.
Parameters
Section titled “Parameters”string
Unique name identifier for the ease
EaseFunction
GSAP-compatible easing function (takes progress 0-1, returns eased value)
Returns
Section titled “Returns”Object containing the registered ease for chaining or reference
Example
Section titled “Example”// Register a custom elastic easegsapPlugin.registerCustomEase('elasticOut', (t) => { const c4 = (2 * Math.PI) / 3; return t === 0 ? 0 : t === 1 ? 1 : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;});
// Use in animationsgsap.to(mySprite, { x: 100, duration: 1, ease: 'elasticOut' });
Implementation of
Section titled “Implementation of”IGSAPPlugin
.registerCustomEase
registerEases()
Section titled “registerEases()”registerEases(
eases
):Ease
Defined in: plugins/GSAPPlugin.ts:438
Registers multiple custom ease functions with GSAP in a single operation. Efficient batch registration for multiple custom eases.
Parameters
Section titled “Parameters”Object mapping ease names to ease functions
Returns
Section titled “Returns”The complete map of all registered eases
Example
Section titled “Example”// Register a suite of game-specific easesgsapPlugin.registerEases({ 'jumpEase': (t) => t * t * (3 - 2 * t), 'impactEase': (t) => 1 - Math.cos(t * Math.PI / 2), 'floatEase': (t) => Math.sin(t * Math.PI / 2), 'snapEase': (t) => t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2});
Implementation of
Section titled “Implementation of”revertAll()
Section titled “revertAll()”revertAll(
contextId?
):void
Defined in: plugins/GSAPPlugin.ts:638
Reverts all animations in the specified context or all contexts to their initial state. Animation targets return to their original property values before the animation started.
Parameters
Section titled “Parameters”contextId?
Section titled “contextId?”string
Optional context identifier. If omitted, reverts all animations in all contexts
Returns
Section titled “Returns”void
Example
Section titled “Example”// Reset UI to initial stategsapPlugin.revertAll('uiAnimations');
// Reset everything for game restartgsapPlugin.revertAll();
// Reset temporary effectsgsapPlugin.revertAll('screenEffects');
Implementation of
Section titled “Implementation of”revertGlobal()
Section titled “revertGlobal()”revertGlobal():
void
Defined in: plugins/GSAPPlugin.ts:728
Reverts all animations within the global animation context to their initial state. Only affects animations in the global context, not custom contexts.
Returns
Section titled “Returns”void
Example
Section titled “Example”// Reset only global animationsgsapPlugin.revertGlobal();
// Reset global animations while preserving context statesgsapPlugin.revertGlobal();// Context-specific animations remain unchanged