UNPKG

@kcirtaptrick/framer-motion

Version:

A simple and powerful React animation library

29 lines (28 loc) 894 B
import { RefObject } from "react"; import { ScrollMotionValues } from "./utils"; /** * Returns MotionValues that update when the provided element 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`. * * This element must be set to `overflow: scroll` on either or both axes to report scroll offset. * * ```jsx * export const MyComponent = () => { * const ref = useRef() * const { scrollYProgress } = useElementScroll(ref) * * return ( * <div ref={ref}> * <motion.div style={{ scaleX: scrollYProgress }} /> * </div> * ) * } * ``` * * @public */ export declare function useElementScroll(ref: RefObject<HTMLElement>): ScrollMotionValues;