Skip to content
Prevent page scrolling
Branch: master
Clone or download
Latest commit 71ed6b7 Dec 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Fix lint errors Dec 8, 2018
test 0.4.0 Dec 26, 2017
.babelrc Upgrade dependencies Dec 8, 2018
.codeclimate.yml Update CI configs Dec 8, 2018
.editorconfig v0.3.0 Oct 7, 2016
.eslintrc Upgrade dependencies Dec 8, 2018
.gitignore 0.4.0 Dec 26, 2017
.travis.yml Update CI configs Dec 8, 2018
LICENSE add LICENSE / update README Sep 8, 2015
README.md update README Feb 22, 2018
jest.config.js 0.4.0 Dec 26, 2017
package-lock.json
package.json 0.4.1 Dec 8, 2018

README.md

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

API

.on([element], [options])

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

  • [element] - DOM Element. Defaults to document.scrollingElement
  • [options] - Change the initial options. Defaults to:
{
    disableWheel: true,
    disableScroll: true,
    disableKeys: true,
    keyboardKeys: [32, 33, 34, 35, 36, 37, 38, 39, 40]
}

.off()

Re-enable page scrolling and remove the listeners.


Inspired by jquery-disablescroll

You can’t perform that action at this time.