Skip to main content

use-on-page-scroll

Installation#

yarn add @uplift-ltd/use-on-page-scroll

API#

useOnPageScroll#

Hook to handle scroll up/down events. Returns current and previous y position. Cleans up after itself.

import { useOnPageScroll } from "@uplift-ltd/use-on-page-scroll";
useOnPageScroll({
onScrollUp: ([newYPosition, lastYPosition]) => {
console.log(newYPosition, lastYPosition);
},
onScrollDown: ([newYPosition, lastYPosition]) => {
console.log(newYPosition, lastYPosition);
},
});