# @sichangi/virtual-scroll

> Smooth fake scroll using CSS transform

Latest version **1.4.4** (published 2020-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sichangi/virtual-scroll
pnpm add @sichangi/virtual-scroll
yarn add @sichangi/virtual-scroll
bun add @sichangi/virtual-scroll
```

## 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.4.4 |
| Published | 2020-11-24 |
| First published | 2019-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 18.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | = |
| Maintainers | mecolela |
| Keywords | virtual, scroll, smooth |

## Links

- npm: https://www.npmjs.com/package/@sichangi/virtual-scroll
- Repository: https://github.com/sichangi/virtual-scroll
- Issues: https://github.com/sichangi/virtual-scroll
- npm.io page: https://npm.io/package/@sichangi/virtual-scroll

## Dependencies (2)

- [tiny-emitter](https://npm.io/package/tiny-emitter.md) ^2.1.0
- [bindall-standalone](https://npm.io/package/bindall-standalone.md) ^1.0.5

## Recent versions

- 1.4.4 (latest) — 2020-11-24
- 1.4.3 — 2020-11-24
- 1.4.2 — 2020-11-23
- 1.4.0 — 2019-11-14
- 1.3.9 — 2019-04-07
- 1.3.8 — 2019-04-07
- 1.3.3 — 2019-01-20
- 1.3.2 — 2019-01-19
- 1.3.1 — 2019-01-19

## README

virtual-scroll
=====
[![pipeline status](https://gitlab.com/mecolela/virtual-scroll/badges/master/pipeline.svg)](https://gitlab.com/mecolela/virtual-scroll/commits/master)

Custom scroll event with inertia/momentum, touch and keyboard compatible.
> See this [article](http://www.everyday3d.com/blog/index.php/2014/08/18/smooth-scrolling-with-virtualscroll/) for the original authors description.

### Goals of the fork
- Support browser and commonjs environments
- Add SSR environment support
- Provide an [example](./example.html) usage

### Installation
```
yarn add @sichangi/virtual-scroll
```

### Usage & API

Return a new instance of VirtualScroll. See the options below.
```js
const instance = new VirtualScroll(options)
```

Listen to the scroll event using the specified function (fn) and optional context.
```js
instance.on(fn, context)
```

Remove the listener.
```js
instance.off(fn, context)
```

Will remove all events and unbind the DOM listeners.
```js
instance.destroy()
```

Events note:
Each instance will listen only once to any DOM listener.These listener are enabled/disabled automatically. However, it's a good practice to always call `destroy()` on your VirtualScroll instance, especially if you are working with a SPA.

### Options
| name   |   default     |  description |
|:----------|:-------------|:------|
| el |  window | the target element for mobile touch events |
| mouseMultiplier |  1  |  General multiplier for all mousewheel (including Firefox) |
| touchMultiplier   | 2 |  Mutiply the touch action by this modifier to make scroll faster than finger movement. |
| firefoxMultiplier | 15 |  Firefox on Windows needs a boost, since scrolling is very slow. |
| keyStep | 120 | How many pixels to move with each key press. |
| preventTouch | false | If true, automatically call `e.preventDefault` on touchMove. |
| unpreventTouchClass | vs-touchmove-allowed |  Elements with this class won't `preventDefault` on touchMove. For instance, useful for a scrolling text inside a VirtualScroll-controled element. |
| limitInertia | false | if true, will leverage [Lethargy](https://github.com/d4nyll/lethargy) to avoid everlasting scroll events (mostly on Apple Mouse, Trackpad, and free-wheel mouse). |
| passive | undefined | if used, will use [passive events declaration](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Improving_scrolling_performance_with_passive_listeners) for the wheel and touch listeners. Can be true or false. |
| disableUserInput | false | if true, does not listen for scroll events  |

### License
MIT.

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