framer-motion
Version:
A simple and powerful React animation library
23 lines (22 loc) • 826 B
TypeScript
import { ScrollMotionValues } from "./utils";
/**
* Returns MotionValues that update when the viewport scrolls:
*
* - `scrollX` — Horizontal scroll distance in pixels.
* - `scrollY` — Vertical scroll distance in pixels.
* - `scrollXProgress` — Horizontal scroll progress between `0` and `1`.
* - `scrollYProgress` — Vertical scroll progress between `0` and `1`.
*
* **Warning:** Setting `body` or `html` to `height: 100%` or similar will break the `Progress`
* values as this breaks the browser's capability to accurately measure the page length.
*
* ```jsx
* export const MyComponent = () => {
* const { scrollYProgress } = useViewportScroll()
* return <motion.div style={{ scaleX: scrollYProgress }} />
* }
* ```
*
* @public
*/
export declare function useViewportScroll(): ScrollMotionValues;