1.0.0 • Published 9 months ago

react-use-scroll-snap v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

react-use-scroll-snap

A minimal React Hook for JavaScript scroll snapping. The Hook primarily snaps to elements using the wheel and touchmove events. Please reference the example folder on how to use the Hook.

API

Properties

PropertyTypeDefaultDescriptionRequired
refReact.RefObject<HTMLElement>N/AParent element of the scroll items.Yes
durationnumber100Snap animation length in miliseconds.No
isArrowKeysEnabledbooleanTrueEnables the up and down arrow keys for snapping.No
isDirectionEnabledbooleanTruePrioritizes scroll direction over element visibility in the viewport.No

Return Object

PropertyTypeDescription
stateReact.RefObject<ScrollState>The internal state object used to track scroll information.
goto(index: number) => voidA function that will scroll to the element at the specified index.

Installation

The package can be installed using npm. The package is written in TypeScript and exports the type declaration file in the distribution.

npm install react-use-scroll-snap

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

1.0.0

9 months ago

0.0.4

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago