Automatically scrolls the element when the cursor approaches the boundaries.
npm install react-tiny-autoscrollAutomatically scrolls the element when the cursor approaches the boundaries.
Mostly helpful when used in combination with drag and drop-like components which do not support scrollable containers.
``shell`
npm install react-tiny-autoscroll
or
`shell`
yarn add react-tiny-autoscroll
`JSX
const containerRef = useRef();
useAutoScroll({
containerRef,
});
// Making our container scrollable
const style: CSSProperties = {
height: 400,
overflowY: "auto",
border: "1px solid red",
};
return (
API
-
containerRef - reference to the scrollable container
- skip - lets you disable/enable the scrolling
- threshold - distance to boundaries where scrolling will start
- maxSpeed` - maximum number of pixels allowed to scroll in 10ms