Report a problem or share feedback← Catalog
Track element within viewport
freemotion/scroll-track-element-in-viewport
An example of tracking an element within the viewport using Motion for React's useScroll hook.
$
pnpm add motion # then adapt the free source from https://motion.dev/examples/react-scroll-track-element-in-viewportnpm deps: motion

- Source
- Motion (motion.dev)
- Kind
- transition
- Categories
- transition, scroll-effect
- Use as
- recipe — technique you apply to your own markup
- Applies to
- scroll-effectnavigation
- Motion
- on scroll · medium · motion · medium cost
- Tags
- motion, useScroll
- Licence
- motion / motion/react / motion-v are MIT. Motion+ (premium components, example source, AI Kit pro tools) is paid — one-time Personal licence or per-seat Business.
- Live demo
- motion.dev
- Docs
- motion.dev
Similar
Compare all 4 →- Scroll Direction: Hide Headermotion/scroll-hide-headerHeader that hides on scroll down and returns on scroll up (useMotionValueEvent). Great default for marketing navbars. Free example (motion is MIT); copy and adapt the source from the example page.
- Scroll-linked animationsmotion/scroll-linkeduseScroll + useTransform: progress bars and parallax tied to scroll position. Medium-intensity; keep it to one element per viewport. Free example (motion is MIT); copy and adapt the source from the example page.
- Element scroll-linked animationmotion/scroll-containerAn example of a scroll-linked animation using a specific element's scroll position using Motion for React's useScroll hook.