spz-interact-observer
When to use
spz-interact-observer observes scroll or mousemove interactions and applies CSS transform effects (parallax, sticky positioning, hover 3D, etc.) to a target element.
Use it when you need to:
- Create parallax scroll effects (translate, scale)
- Implement sticky header / footer that stacks with other sticky elements
- Add 3D tilt effects on mouse hover
- Toggle element visibility based on scroll distance
Supported layout
- All layouts are supported
Usage
Example
Scroll parallax
Sticky positioning
Rely on another sticky element
Mousemove 3D tilt
Scroll-distance toggle (show/hide elements)
When from and to are not transform properties but elementId.attributeName pairs, the component toggles boolean attributes on those elements based on scroll distance.
Attributes
Supported transform properties
translateX, translateY, translateZ, scaleX, scaleY, rotateX, rotateY, rotateZ
Actions
change
Recalculate position based on the observe-id / rely-id element. Useful when the observed element's size changes dynamically.
Example:
Behavior
- Parallax mode — When both
fromandtocontain transform properties (e.g.translateY,scaleX), the component interpolates between them as the element scrolls through the viewport. - Sticky mode — When
tocontainsposition:toporposition:bottom, the component manages sticky visibility and stacks with other sticky elements. - Rely/observe mode — When
observe-idorrely-idis set, the target element's top/bottom offset is adjusted based on the observed element's height and sticky state. - Scroll-distance mode — When
from/toare not transform properties, the component toggles boolean attributes on referenced elements based on scroll distance. - Mousemove mode — When
interact="mousemove", the component applies 3D rotation and translation based on cursor position within the target element.
Notes
- This component does not emit custom events.
- In mousemove mode, transforms reset to
noneon mouseout. - iOS Safari bottom bar compensation is automatically applied in bottom-sticky mode.