disable-scroll
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

disable scroll

NPM version build status Maintainability Test Coverage

Prevent page scrolling like a boss.
Supports scroll, wheel, touchmove, keydown events.

Demo

Setup

npm

npm install --save disable-scroll

and import it

import disableScroll from 'disable-scroll';

Usage

disableScroll.on(); // prevent scrolling
...
disableScroll.off(); // re-enable scroll

If you need to support legacy browsers you need to include the scrollingelement polyfill.

API

.on(element?: Element, options?: Options)

Disable page scroll by adding event listeners and locking the scroll position.

Options defaults to:

{
    authorizedInInputs: [32, 37, 38, 39, 40],
    disableKeys: true,
    disableScroll: true,
    disableWheel: true,
    keyboardKeys: [32, 33, 34, 35, 36, 37, 38, 39, 40],
}

.off()

Re-enable page scrolling and remove the listeners.

Issues

If you find a bug, please file an issue on our issue tracker on GitHub.

License

MIT


Inspired by jquery-disablescroll

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.6.0
    8,306
    • latest

Version History

Package Sidebar

Install

npm i disable-scroll

Weekly Downloads

7,280

Version

0.6.0

License

MIT

Unpacked Size

21.7 kB

Total Files

10

Last publish

Collaborators

  • gilbarbara