Quick Start
Hello World Animation
Fade in a text layer when the visual appears:- Add custom JS to your visual
- Set layer ID to
my-text-layer(bottom of layer properties) - Turn off default transition on that layer
Core Concepts
The visualLink Object
visualLink connects your JavaScript to the visual lifecycle. Always check it exists:
When writing custom JavaScript for visuals, you have access to the
visualLink object that provides methods to interact with your visual canvas. It’s the link between the code and the visual lifecycle and data. Every layer is accessible via the visualLink.Getting Elements
Never usedocument.querySelector - visuals renderer places elements in different contexts on the page, there is no guarantee that the querySelector will query the element you expect it to return.
visualLink.getCanvasElement():
The Play State Manager
visualLink.playStateManager controls when your visual appears and disappears. It fires events at key moments in the visual’s lifecycle.
pm.on().
Lifecycle Events
Visuals have 3 key moments:cuein → enter → leave
GSAP Basics
Three Animation Methods
Common Properties
Complete Examples
Example 1: Simple Fade In
Example 2: Slide In + Fade Out
- Enter: Slides in from left with fade
- Leave: Fades out
Example 3: Multiple Layers
Example 4: Using Timelines
For complex multi-step animations:- Logo scales up
- Title fades in from top (slightly before logo finishes)
- Subtitle fades in
Example 5: Full In/Out with Reset
cuein: Reset both animationsenter: Slide in from leftleave: Slide out to right
cuein to prevent state issues.
Transition Settings
Found in Visual settings below tag editor. Controls overall visual transition behavior.Default
Layers transition independently. Each layer uses its own timing. Use when: Simple visuals with independent layer animations.Layer Based
Visual waits for ALL layers to finish transitioning. Duration = sum of all layer transitions Use when: Coordinated multi-layer animations where all must complete.Visual Based
Fixed duration for entire visual, layers animate within that time. Settings:- In Duration (ms): Time to show visual
- Out Duration (ms): Time to hide visual
Visual Fixed
Single fixed-length visual. No individual layer control. Settings:- In Duration (ms): Show time
- Out Duration (ms): Hide time
- Layer transitions disabled
Common Patterns
Pattern: Layer That Only Animates In
Pattern: Continuous Animation
Pattern: Sequence Multiple Animations
Pattern: Overlap Animations
Troubleshooting
Animation doesn’t run
-
typeof visualLink !== "undefined"wrapper exists - Layer ID matches
getCanvasElement("id") - Default transition disabled on animated layers
- Console for errors
Animation runs but looks wrong
- Using lifecycle events correctly (
cuein/enter/leave) - Reset animations in
cueinfor repeatable playback - Transition Settings mode matches intent
Element not found
- Layer ID set in properties (bottom of panel)
- Using
visualLink.getCanvasElement()notdocument.querySelector - ID has no
#prefix ingetCanvasElement("id")
Animation plays multiple times
Solution: Check if active before restarting:Visual data not updating
Access visual data viavisualLink.data:
Best Practices
- Always check
visualLinkexists before any code - Always use
visualLink.getCanvasElement()for DOM queries - Reset animations in
cueinfor reliable repeated playback - Disable default transitions on GSAP-animated layers
- Use timelines for multi-step animations
- Check
isActive()before restarting animations - Keep durations under 1s for snappy UI
- Test with repeated plays (
cuein→enter→leave)