Vue directive for an easy use of the body-scroll-lock library.
npm install v-body-scroll-lock- Installation
- How to use
- Options
- Issues
- Contributing
yarn add v-body-scroll-lock
`
#### Npm
`
npm i v-body-scroll-lock --save
`How to use
Add v-body-scroll-lock or v-bsl (short version) to the element which you want to keep scrollable.
v-body-scroll-lock and v-bsl take a boolean as an argument like v-body-scroll-lock="modalIsOpen"
If modalIsOpen is true, body scroll lock will be applied to other elements except for the one which has v-body-scroll-lock="modalIsOpen"#### Code
For a more deep example checkout
App.vue in /src/App.vue.
`html
v-show="modalIsOpen"
class="modal">
This is a modal! I am scrollable while the body is not!
`js
`
Options
#### reserveScrollBarGap
Reserves the with of the scrollbar and prevents the unpleasant flickering effect that can occur when locking the body scroll.
More info here.To enable the
reserveScrollBarGap option add :reserveScrollBarGap after v-body-scroll-lock or v-bsl.
Example: v-body-scroll-lock:reserveScrollBarGap="modalIsOpen"`.