MCPcopy Create free account
hub / github.com/adobe/react-spectrum / onScroll

Function onScroll

packages/dev/s2-docs/src/MobileHeader.tsx:151–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 let [start, end] = animationRange.split(' ').map(v => parseInt(v, 10));
150 let animations = ref.current.getAnimations({subtree: true});
151 let onScroll = () => {
152 // Calculate animation time based on percentage of animationRange * duration.
153 let time = Math.max(0, Math.min(end, window.scrollY - start) / (end - start)) * 1000;
154 for (let animation of animations) {
155 animation.currentTime = time;
156 }
157 };
158
159 window.addEventListener('scroll', onScroll, {passive: true});
160 return () => window.removeEventListener('scroll', onScroll);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected