Gathering detailed insights and metrics for v-scroll-lock
Gathering detailed insights and metrics for v-scroll-lock
Gathering detailed insights and metrics for v-scroll-lock
Gathering detailed insights and metrics for v-scroll-lock
A Vue.js directive for body scroll locking without breaking scrolling of a target element.
npm install v-scroll-lock
Typescript
Module System
Node Version
NPM Version
TypeScript (82.24%)
Vue (10.77%)
JavaScript (5.64%)
HTML (1.34%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
184 Stars
23 Commits
12 Forks
3 Watchers
27 Branches
2 Contributors
Updated on Apr 01, 2025
Latest Version
1.3.1
Package Id
v-scroll-lock@1.3.1
Unpacked Size
221.14 kB
Size
72.90 kB
File Count
36
NPM Version
6.14.6
Node Version
10.22.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
39
A Vue.js directive for body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus). Built on top of https://github.com/willmcpo/body-scroll-lock
Preventing the body from scrolling when you have a modal/lightbox/flyout/nav-menu open on all devices can be a huge pain. This package wraps https://github.com/willmcpo/body-scroll-lock into an easy to use Vue.js directive.
Demo can be viewed here: http://v-scroll-lock.peterhegman.com/
Source code for demo can be viewed in src/Demo.vue
1yarn add v-scroll-lock
1npm install v-scroll-lock --save
1import VScrollLock from 'v-scroll-lock' 2 3Vue.use(VScrollLock)
Download latest v-scroll-lock.min.js
from https://github.com/phegman/v-scroll-lock/releases
Include using a <script>
tag
1<script src="v-scroll-lock.min.js"></script>
Once the plugin is installed the v-scroll-lock
directive can be used in any of your components. When the value of the directive is true
scrolling will be locked on all elements except the element the directive is bound to.
Here is an example of how you may implement it in a basic modal. Please note the below example is to demonstrate usage of the v-scroll-lock
directive and is not a complete implementation of a modal. See src/components/Modal.vue
for a more in depth example.
1<template> 2 <div class="modal" v-if="open"> 3 <button @click="closeModal">X</button> 4 <div class="modal-content" v-scroll-lock="open"> 5 <p>A bunch of scrollable modal content</p> 6 </div> 7 </div> 8</template> 9 10<script> 11export default { 12 name: 'Modal', 13 data() { 14 return { 15 open: false, 16 } 17 }, 18 methods: { 19 openModal() { 20 this.open = true 21 }, 22 closeModal() { 23 this.open = false 24 }, 25 }, 26} 27</script>
Options can be passed when installing the directive:
1import VScrollLock from 'v-scroll-lock' 2 3Vue.use(VScrollLock, { 4 bodyScrollOptions: { 5 reserveScrollBarGap: true, 6 }, 7})
See https://github.com/willmcpo/body-scroll-lock#options for full list of options.
To make using this directive easier body-scroll-lock is included in the package. In the case that you would like to use a version different than the packaged version this can be specified in the plugin options. Also note that v-scroll-lock-no-dep.esm.js
should be imported to prevent duplicate code in your bundle. See example below:
1import VScrollLock from 'v-scroll-lock/dist/v-scroll-lock-no-dep.esm' 2import { enableBodyScroll, disableBodyScroll } from 'body-scroll-lock' 3 4Vue.use(VScrollLock, { 5 enableBodyScroll, 6 disableBodyScroll, 7})
Please open an issue for support.
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/16 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
Project has not signed or included provenance with any releases.
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
110 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More