Skip to content

nuxt-contrib/lock-body-scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lock body scroll

🌈 Lock/unlock body scrolling when modal is opened

Standard JS Circle CI Codecov npm version npm downloads

Installation

$ yarn add lock-body-scroll

or

$ npm i lock-body-scroll

Usage

ES modules

import createLocker from 'lock-body-scroll'

const locker = createLocker()

// or

const locker = createLocker(options)

locker.lock()

locker.unlock()

CommonJS

const createLocker = require('lock-body-scroll')

const locker = createLocker()

locker.lock()

locker.unlock()

Browser

HTML:

<head>
  <script src="https://cdn.jsdelivr.net/npm/lock-body-scroll" />
</head>

JavaScript:

const locker = window.createLocker()

locker.lock()

locker.unlock()

Options

scrollElement

Default: document.scrollingElement || document.documentElement

The dom element which is for locking scrolling

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published