Socket
Socket
Sign inDemoInstall

react-use-scroll-snap

Package Overview
Dependencies
2
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-use-scroll-snap

A React Hook for JavaScript scroll snapping.


Version published
Weekly downloads
573
decreased by-1.21%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 19 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc