https://github.com/bukacekd/lock-scroll
A set of methods to lock scrolling within an element or an entire page.
https://github.com/bukacekd/lock-scroll
android body desktop ios lock mobile modal overflow scroll scrollbar tablet toggle
Last synced: 3 months ago
JSON representation
A set of methods to lock scrolling within an element or an entire page.
- Host: GitHub
- URL: https://github.com/bukacekd/lock-scroll
- Owner: bukacekd
- License: mit
- Created: 2023-08-02T10:23:47.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-04-04T15:04:43.000Z (3 months ago)
- Last Synced: 2026-04-04T15:59:56.373Z (3 months ago)
- Topics: android, body, desktop, ios, lock, mobile, modal, overflow, scroll, scrollbar, tablet, toggle
- Language: TypeScript
- Homepage: https://bukacekd.github.io/lock-scroll
- Size: 206 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Lock scroll
A set of methods to lock scrolling within an element or an entire page on mobile devices, tablets and desktops.
Live Demo: https://bukacekd.github.io/lock-scroll
## Features
- [easy to use](#usage)
- compatible with Android, IOS, MacOS and Windows
- compatible with mobile devices, tablets and desktops
- preserves the space corresponding to the width of the scrollbar
## Installation
Npm
```bash
npm install @js4y/lock-scroll
```
CDN
```bash
```
## Usage
Npm
```javascript
import {lockScroll, unlockScroll} from '@js4y/lock-scroll';
// lock scrolling
lockScroll();
// unlock scrolling
unlockScroll();
```
CDN
```javascript
// lock scrolling
js4y.scrolling.lockScroll();
// unlock scrolling
js4y.scrolling.unlockScroll();
<script>
```
## Methods
### lockScroll(target?: HTMLElement): void
Lock scrolling within an element or an entire page.
```javascript
// lock page scrolling
lockScroll();
// lock scrolling for specific element
lockScroll(document.getElementById('scrollable-element'));
```
### unlockScroll(target?: HTMLElement): void
Unlock scrolling within an element or an entire page.
```javascript
// unlock page scrolling
unlockScroll();
// unlock scrolling for specific element
unlockScroll(document.getElementById('scrollable-element'));
```
## Browser support
|  |  |  |  |  |
| :-: | :-: | :-: | :-: | :-: |
| Chrome 69+ | Edge 79+ | Firefox 41+ | Opera 56+ | Safari 12.1+ |
## License
The project is licensed under [MIT license](https://opensource.org/license/mit/).
## Related
- [CountUp](https://github.com/bukacekd/count-up) - A tiny dependency-free JavaSript library for animating numeric values.
- [Dialog](https://github.com/bukacekd/dialog) - A tiny dependency-free JavaSript ES6 library built on a dialog element with minimal configuration.
- [Loader](https://github.com/bukacekd/loader) - A tiny dependency-free javascript loading spinner component with minimal configuration.