🌈 Lock/unlock body scrolling when modal is opened
$ yarn add lock-body-scroll
or
$ npm i lock-body-scroll
import createLocker from 'lock-body-scroll'
const locker = createLocker()
// or
const locker = createLocker(options)
locker.lock()
locker.unlock()
const createLocker = require('lock-body-scroll')
const locker = createLocker()
locker.lock()
locker.unlock()
HTML:
<head>
<script src="https://cdn.jsdelivr.net/npm/lock-body-scroll" />
</head>
JavaScript:
const locker = window.createLocker()
locker.lock()
locker.unlock()
Default: document.scrollingElement || document.documentElement
The dom element which is for locking scrolling
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.