# rescript-body-scroll-lock

> ReScript bindings for body-scroll-lock

Latest version **3.1.0** (published 2021-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install rescript-body-scroll-lock
pnpm add rescript-body-scroll-lock
yarn add rescript-body-scroll-lock
bun add rescript-body-scroll-lock
```

## 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 | 3.1.0 |
| Published | 2021-05-21 |
| First published | 2021-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dmitry Zakharov |
| Maintainers | dzakh |
| Keywords | rescript, bindings, body-scroll-lock |

## Links

- npm: https://www.npmjs.com/package/rescript-body-scroll-lock
- Repository: https://github.com/DZakh-packages/rescript-body-scroll-lock
- Issues: https://github.com/DZakh-packages/rescript-body-scroll-lock/issues
- npm.io page: https://npm.io/package/rescript-body-scroll-lock

## Recent versions

- 3.1.0 (latest) — 2021-05-21

## README

# rescript-body-scroll-lock

ReScript bindings for [body-scroll-lock](https://github.com/willmcpo/body-scroll-lock).

Exposed as `BodyScrollLock` module.

**rescript-body-scroll-lock** X.y.\* means it's compatible with **body-scroll-lock** X.y.\* version.

## Installation

```bash
npm install body-scroll-lock rescript-body-scroll-lock
```

rescript-body-scroll-lock should be added to bs-dependencies in your bsconfig.json:

```diff
{
  //...
  "bs-dependencies": [
    // ...
+   "rescript-body-scroll-lock"
  ],
  //...
}
```

## Methos

### disableBodyScroll

Disables body scroll while enabling scroll on target element

```re
open Webapi.Dom
switch document |> Document.querySelector(".js-scrollable-modal") {
| Some(scrollableModalEl) => BodyScrollLock.disableBodyScroll(scrollableModalEl, ())
| None => () // do nothing
}
```

### enableBodyScroll

Enables body scroll and removing listeners on target element

```re
open Webapi.Dom
switch document |> Document.querySelector(".js-scrollable-modal") {
| Some(scrollableModalEl) => BodyScrollLock.enableBodyScroll(scrollableModalEl)
| None => () // do nothing
}
```

### clearAllBodyScrollLocks

Clears all scroll locks

```re
clearAllBodyScrollLocks()
```

## BodyScrollOptions

### reserveScrollBarGap

**optional, default:** as in library

```re
BodyScrollLock.disableBodyScroll(
  targetElement,
  ~options=BodyScrollLock.bodyScrollOptions(~reserveScrollBarGap=true, ()),
  (),
)
```

### allowTouchMove

**optional, default:** as in library

```re
BodyScrollLock.disableBodyScroll(
  el,
  ~options=BodyScrollLock.bodyScrollOptions(
    ~allowTouchMove=el => {el |> Webapi.Dom.Element.hasAttribute("data-with-scroll")},
    (),
  ),
  (),
)
```

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