All Projects → jamesplease → prevent-scroll

jamesplease / prevent-scroll

Licence: MIT license
[unmaintained] Reliably disable scrolling

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

prevent-scroll

Reliably disable scrolling

Travis build status Test Coverage Dependency Status devDependency Status

Motivation

Preventing a user from scrolling is a surprisingly challenging thing to do on the web. This library is the most robust solution I know of to disable scrolling.

Features

✓ Mobile and desktop support
✓ Prevents scrolling through keyboard inputs
✓ Never loses the position of the scrollbar
✓ Never causes the scrollbar to appear or disappear unnecessarily
✓ Solid browser support
✓ Zero dependencies

Installation

The recommended way to install this package is through npm.

npm install prevent-scroll

API

preventScroll.on()

Disables scrolling.

preventScroll.off()

Enables scrolling.

Example Usage

import preventScroll from 'prevent-scroll';

// Disable scrolling
preventScroll.on();

// Allow scrolling
preventScroll.off();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].