spz-animation
When to use
spz-animation applies a CSS class to one or more target elements in response to various triggers — viewport visibility, scroll, click, mousemove, or manual invocation.
Use it when you need to:
- Play entrance animations when elements scroll into view
- Track scroll position via CSS variables for scroll-linked effects
- Trigger animations on click or hover
- Coordinate animation across multiple targets with ordering
Supported layout
logic
Example
Fade in on scroll into view
Scroll-linked CSS variable
The target element receives the CSS variable --spzanim-scroll-rect-top which you can use in CSS to drive scroll-linked effects.
Click trigger
Manual trigger
Ordered entrance
Each .list-item receives the CSS variable --spzanim-order (0, 1, 2, ...) which you can use in animation-delay for staggered effects.
Attributes
CSS variables
The component sets the following CSS variables on target elements, depending on the trigger type:
Actions
run
Manually trigger the animation. Typically used with trigger="manual".
Example:
Events
Notes
- The
animation-classis added on trigger and removed when the animation ends (unlessonceis set withvisible). style-variablessupports element references like${elementId}and$(selector)for dynamic value computation.