# scroll-lock-a

> A JavaScript library to solve the rolling penetration of modal boxes on mobile and PC

Latest version **1.0.7** (published 2021-03-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install scroll-lock-a
pnpm add scroll-lock-a
yarn add scroll-lock-a
bun add scroll-lock-a
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2021-03-16 |
| First published | 2020-02-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 19.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Qiulonghui |
| Maintainers | qlh15975494639 |
| Keywords | scroll, lock, vue, react, modal, mobile |

## Links

- npm: https://www.npmjs.com/package/scroll-lock-a
- Repository: https://github.com/qiulonghui/scroll-lock
- Homepage: https://github.com/qiulonghui/scroll-lock#readme
- Issues: https://github.com/qiulonghui/scroll-lock/issues
- npm.io page: https://npm.io/package/scroll-lock-a

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2021-03-16
- 1.0.6 — 2020-02-25
- 1.0.5 — 2020-02-22
- 1.0.4 — 2020-02-22
- 1.0.3 — 2020-02-16
- 1.0.2 — 2020-02-16
- 1.0.1 — 2020-02-16

## README

## Scroll-Lock-a
*Features:*
解决移动端和PC端滚动穿透的问题。兼容Safari、QQ浏览器、微信浏览器及大多数安卓原生浏览器

## 安装
    
    $ yarn add scroll-lock-a
    
    or
    
    $ npm install scroll-lock-a

## 使用
##### Vue/ES6

```javascript
// Import the lib
import  { disableBodyScroll, enableBodyScroll } from 'scroll-lock-a';
  
export default {
  mounted() {
    // the target element is the one we would like to allow scroll Element
    this.targetElement = document.querySelector('#targetElementId');
  }

  methods:{
    modalShow() {
      // ... some logic to show element
      this.visible = true;
      // Body Elements disabled scrolling
      disableBodyScroll(this.targetElement); 
    },
    modalClose() {
      this.visible = false;
      // Re-enable scroll 
      enableBodyScroll(this.targetElement);
    }
  }
}
```

## API

| Function | Arguments | Description |
| :--- | :--- | :--- |
| `disableBodyScroll` | `targetElement: HTMLElement` | Disables body element scroll when modal box showed  after |
| `enableBodyScroll` | `targetElement: HTMLElement` | Re-enable body element scroll when modal box closed  before |

---
_Source: https://npm.io/package/scroll-lock-a · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
