react-scroll-edge
TypeScript icon, indicating that this package has built-in type declarations

1.0.30 • Public • Published

react-scroll-edge

Check if scroll is within an offset to the start or end

Example

npm install react-scroll-edge or yarn add react-scroll-edge

function Example() {
    const ref = useRef(null);
    const { start, end } = useScrollEdge(ref, "horizontal", 100);

    return (
        <ul ref={ref}>...</ul>
    )
}

The return object contains ´start´ and ´end´ booleans which are true if the scroll distance is withing the providded offset to the start/beginning.

Function type

useScrollEdge(
    element: RefObject<HTMLElement>,
    orientation: "horizontal" | "vertical",
    offset?: number = 0
): { start: boolean, end: boolean };

Readme

Keywords

none

Package Sidebar

Install

npm i react-scroll-edge

Weekly Downloads

0

Version

1.0.30

License

MIT

Unpacked Size

4.33 kB

Total Files

5

Last publish

Collaborators

  • alvarlagerlof