# scroll-canvas

> Scroll animation in canvas

Latest version **1.0.3** (published 2021-02-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install scroll-canvas
pnpm add scroll-canvas
yarn add scroll-canvas
bun add scroll-canvas
```

## 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.3 |
| Published | 2021-02-07 |
| First published | 2021-02-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 88.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jeffrey Dufour |
| Maintainers | jffrdfr |
| Keywords | scroll, animation, canvas, html5 |

## Links

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

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-02-07
- 1.0.2 — 2021-02-06
- 1.0.1 — 2021-02-06
- 1.0.0 — 2021-02-06

## README

# Scroll Canvas

## Features
* Easy API for creating scroll animations on your website;
* No custom CSS needed;
* Control the speed of the animation by providing the distance of the canvas;
* Scroll Canvas will not calculate the frame positions when it is outside the viewport;
* Example page to get you started (see GIT project).

## Example
Visit the [demo page](https://scrollcanvasstorage.z6.web.core.windows.net/) to see Scroll Canvas in action! _Big props to [Maikel Kerkhoven](https://www.maikelkerkhoven.com) for the artwork._

## Install

```
npm install scroll-canvas
```

## Usage
After installing the package you can import it into your project. Initialize `ScrollCanvas` with a list of images, and dimensions. You must also provide a container element, so it knows where to render the canvas.

```html
<div id="canvas"></div>
``` 

```typescript
import ScrollCanvas from 'scroll-canvas';

const canvas = new ScrollCanvas({
  container: document.getElementById('canvas'),
  distance: 4,
  width: 800,
  height: 800,
  imagePaths: [
    '/assets/images/01.jpg',
    '/assets/images/02.jpg',
    '/assets/images/03.jpg',
    '/assets/images/04.jpg',
    '/assets/images/05.jpg',
    '/assets/images/06.jpg'
  ]
});

canvas.bootstrap();
```
The frames are calculated with the scrollTop property of the document element. Calculating the position will not work when the canvas is placed inside an overflow element. To fix this you must also add the root element when initializing `ScrollCanvas`:
```javascript
const canvas = new ScrollCanvas({
  ...,
  root: document.getElementById('overflowElement')
})
```

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