# @matrix-scrollbar/core

> Matrix Scrollbar in pure javascript

Latest version **1.0.4** (published 2019-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @matrix-scrollbar/core
pnpm add @matrix-scrollbar/core
yarn add @matrix-scrollbar/core
bun add @matrix-scrollbar/core
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-06-18 |
| First published | 2019-06-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rasmus Josefsson |
| Maintainers | rajjejosefsson |

## Links

- npm: https://www.npmjs.com/package/@matrix-scrollbar/core
- npm.io page: https://npm.io/package/@matrix-scrollbar/core

## Dependencies (1)

- [@matrix-scrollbar/utils](https://npm.io/package/@matrix-scrollbar/utils.md) ^1.0.1

## Recent versions

- 1.0.4 (latest) — 2019-06-18
- 1.0.3 — 2019-06-16
- 1.0.2 — 2019-06-16
- 1.0.1 — 2019-06-16
- 1.0.0 — 2019-06-16
- 0.0.17 — 2019-06-16
- 0.0.16 — 2019-06-16
- 0.0.15 — 2019-06-15
- 0.0.14 — 2019-06-15
- 0.0.13 — 2019-06-15
- 0.0.12 — 2019-06-14
- 0.0.11 — 2019-06-14
- 0.0.10 — 2019-06-14
- 0.0.6 — 2019-06-13
- 0.0.5 — 2019-06-13
- … 4 more at https://npm.io/package/@matrix-scrollbar/core/versions

## README

# @matrix-scrollbar/core 🔭👩‍🚀

## Installation

This module is distributed via [npm](https://www.npmjs.com/package/@matrix-scrollbar/core) which is bundled with node and should be installed as one of your project's `dependencies`:

```cmd
npm install --save @matrix-scrollbar/core
```

### Alternative with just a script tag

```js
<script src="https://unpkg.com/@matrix-scrollbar/core@0.0.13/lib/index.umd.js"></script>;

var matrixScrollbar = new MatrixScrollbar({ options });

// ..

// Updates the scrollbar / scroll thumb
matrixScrollbar.recount();

// Unsubscribe from all event listeners that are setup behind the scene
matrixScrollbar.disconnect();
```

## Example

> [Try it out in the browser](https://codesandbox.io/s/matrix-scrollbarcore-tn2r0)

```jsx
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script src="https://unpkg.com/@matrix-scrollbar/core@0.0.13/lib/umd/index.js"></script>

    <style>
      .list {
        border: 2px solid black;
        height: 400px;
        width: 300px;
        list-style: none;
        padding: 0;
      }

      li {
        height: 100px;
      }

      li:nth-child(odd) {
        background: #995cc92e;
      }
    </style>

    <ul class="list"></ul>

    <script>
      var viewport = document.querySelector(".list");

      new Array(100).fill(null).forEach((item, index) => {
        var li = document.createElement("li");
        li.innerText = index;
        viewport.appendChild(li);
      });

      var matrixScrollbar = new MatrixScrollbar({
        scrollViewport: viewport,
        autoHideThumb: false
      });
    </script>
  </body>
</html>

```

---

## Props/Settings

| key              | default  | description                                     |
| ---------------- | -------- | ----------------------------------------------- |
| `autoHideThumb`  | true     | boolean                                         |
| `minThumbHeight` | 30       | number                                          |
| `scrollViewport` | optional | HTMLElement                                     |
| `totalHeight`    | optional | number: rare cases to help with the calculation |
| `className`      | optional | string: setting class to the most outer element |

## Styling

| class                    | active (appended)               |
| ------------------------ | ------------------------------- |
| `matrixScrollbar__thumb` | `matrixScrollbar__thumb-active` |
| `matrixScrollbar__rail`  | `matrixScrollbar__rail-active`  |

---
_Source: https://npm.io/package/@matrix-scrollbar/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
