# dual-side-scroll

> It's a tiny freeware library on TypeScript to sinhronize page scrolling and navigation meny-bar.

Latest version **1.2.3** (published 2021-03-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install dual-side-scroll
pnpm add dual-side-scroll
yarn add dual-side-scroll
bun add dual-side-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.2.3 |
| Published | 2021-03-10 |
| First published | 2020-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Evgeny Brega |
| Maintainers | eabrega |
| Keywords | scrollspy, scroll progress, scroll, scroll-progress, dual-side scroll, javascript, typescript, library, scrolling, html5, web |

## Links

- npm: https://www.npmjs.com/package/dual-side-scroll
- Repository: https://github.com/eabrega/scrollspy
- Homepage: https://eabrega.github.io/scrollspy/
- Issues: https://github.com/eabrega/scrollspy/issues
- npm.io page: https://npm.io/package/dual-side-scroll

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.2.3 (latest) — 2021-03-10
- 1.2.2 — 2020-11-28
- 1.2.1 — 2020-11-15
- 1.2.0 — 2020-10-24
- 1.1.6 — 2020-08-20
- 1.1.5 — 2020-08-19
- 1.1.4 — 2020-08-19
- 1.1.3 — 2020-08-19
- 1.1.2 — 2020-08-19
- 1.1.1 — 2020-08-19
- 1.1.0 — 2020-08-19

## README

# Scroll progress (dual-side-scroll) v1.2.3
[![npm](https://img.shields.io/npm/v/dual-side-scroll?color=green)](https://www.npmjs.com/package/dual-side-scroll)
![npm](https://img.shields.io/npm/dy/dual-side-scroll)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/dual-side-scroll)
[![GitHub license](https://img.shields.io/github/license/jerosoler/Drawflow)](https://github.com/jerosoler/Drawflow/blob/master/LICENSE)


## Assignment
This tiny plugin is designed to show the progress of the page scrolling interactively. There are two types of actions: `onScrolled` and `onChanged`. 
They can be used together or separately.

- `onScrolled` - returns to the progress for each scroll event. It is convenient to use when you need to display progress in real time.
- `onChanged` - works only when one paragraph is replaced to another. This is useful for switching the active menu item in the navigation block.

[LiveDemo](https://eabrega.github.io/scrollspy)

## How does it work?
All you need is a navigation menu with links to the relevant paragraphs in the text. When initializing an object, you need to specify cursor and menu selectors, as well as a callback function.

When the `onScrolled` event is used, an object will be sent to the processing unit:
```typescript
    Progress {
        // id of current paragraph
        Id: string;
        // % of paragraph being reviewed
        Percent: number;
    }
```
When the `onChanged` event is used, the id of the current paragraph will be sent to the processing unit.

When the window is changed in size, the script automatically will be adjuscted to the proportional value. This is sometimes needed in the mobile version. When the device screen is rotated, the scrolling will continue to work correctly.

## Installation

```
npm i dual-side-scroll
```

Take the minified version of the script from `dist` and place it in your application directory. Make sure the plugin connection string is located above the connection string of your scripts.

```html 
<script src="./<your_js_directory>/scroll-progress.min.js"></script>
```

For debugging purposes, there is an unminified version with sourcemap.

## Example

The source code of the page [LiveDemo](https://eabrega.github.io/scrollspy) script.
```javascript
document.addEventListener("DOMContentLoaded", function (event) {
    let currentParagraphName = document.getElementById('current-paragraph-name');
    let currentParagraphPercent = document.getElementById('current-paragraph-percent');

    new ScrollProgress.Init(
        "#cursor",
        "menu",
        progress => {
            currentParagraphName.innerText = document.getElementById(progress.Id).innerText;
            currentParagraphPercent.innerText = progress.Percent + '%';
        },
        id => {
            document.querySelectorAll('a[href*="link"]')
                .forEach(element => 
                    element.classList.remove('active-meny-item')
                );
            document.querySelector(`[href="#${id}"]`).classList
                .add('active-meny-item');
        }
    );
});
```

## Planned updates
* Interactive cursor to scroll the page
* Bookmarks in paragraphs

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