Skip to main content

useScrollContainer

import { useScrollContainer } from 'react-indiana-drag-scroll';

export const Example = () => {
const scrollContainer = useScrollContainer(options);
return (
<div ref={scrollContainer.ref}>
{/* scrollable content */}
</div>
)
};

Options

FieldTypeDescriptionDefault
onScroll() => voidInvoked when user scrolls the container
onEndScroll() => voidInvoked when scrolling is over completely
onStartScroll() => voidInvoked when scrolling starts
mouseScrollConfiguration, booleanThe configuration of mouse scroll. The object's fields is described belowtrue

Configuration

FieldTypeDescriptionDefault
rubberBandbooleanThe flag that indicates that rubber band effect should be enabledtrue
inertiabooleanThe flag that indicates that inertial effect should be enabledtrue
overscrollbooleanThe flag that indicates that overscroll effect should be enabled (experimental)false
cursorbooleanThe flag that indicates that cursor should be changed on dragtrue
activationDistanceNumberThe distance that distinguish click and drag start10
ignoreElementsstringSelector for elements that should not trigger the scrolling behaviour (for example, ".modal, dialog" or "*[prevent-drag-scroll]")
buttonsnumber[]The list of mouse button numbers that will activate the scroll by drag[1]