Lock body scroll without breaking scrolling of a target element (only for touch devices).
# Using npm
npm install
# Using Yarn
yarn add
yarn run dev
yarn run build
yarn run lint
import { Scrollock } from "./scrollock.js";
const targetElement = document.querySelector('#someElement');
const lock = new Scrollock({
element: targetElement
});
let isOpen = false;
document.querySelector('.btn').addEventListener('click', function() {
if (!isOpen) {
lock.disableBodyScroll();
} else {
lock.enableBodyScroll();
}
isOpen = !isOpen;
});
- iOS (Safari 13 & Chrome 76)
- Android (Brave 1.3.2 & Chrome 77)