# @zerofool/show-on-scroll

> Javascript library for animating elements into view when scrolled to

Latest version **0.0.2** (published 2020-12-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @zerofool/show-on-scroll
pnpm add @zerofool/show-on-scroll
yarn add @zerofool/show-on-scroll
bun add @zerofool/show-on-scroll
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-12-01 |
| First published | 2020-11-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @zerofool |
| Maintainers | zerofool |
| Keywords | scroll, scrolling, animating, animation, transition |

## Links

- npm: https://www.npmjs.com/package/@zerofool/show-on-scroll
- Repository: https://github.com/AdamJaggard/show-on-scroll
- Homepage: https://github.com/AdamJaggard/show-on-scroll#readme
- Issues: https://github.com/AdamJaggard/show-on-scroll/issues
- npm.io page: https://npm.io/package/@zerofool/show-on-scroll

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 0.0.2 (latest) — 2020-12-01
- 0.0.1 — 2020-11-24

## README

# Show On Scroll (SoS)

SoS is a javascript library that allows you to transition elements into view when you scroll to them. Currently in a beta stage and being tested.

## Features

- Simple one-way transitions (they don't reverse or reset)
- Transitions are powered by CSS and run buttery smooth
- Multiple element staggering by default (configurable)
- Built in transitions
- Define your own transitions and SoS will handle triggering them
- Based on the IntersectionObserver API
- Written in TypeScript

## Examples

`npm install @zerofool/show-on-scroll`


### Simple
```javascript
import showOnScroll from '@zerofool/show-on-scroll';

showOnScroll('.boxes');
```
We didn't specify a type of transition because `fadeSlideUp` is the default if one isn't supplied.


### Or using a different built-in transition
```javascript
import showOnScroll, { wipeUp } from '@zerofool/show-on-scroll';

showOnScroll('.boxes', wipeUp);
```

### Modifying a built-in transition
```javascript
import showOnScroll, { fadeSlideUp } from '@zerofool/show-on-scroll';

// copy an existing transition, disable staggering
const modifiedTransiton = {
	...fadeSlideUp,
	stagger: 0
};

showOnScroll('.boxes', modifiedTransiton);
```

### Define your own transition
```javascript
import showOnScroll, { makeTransition } from '@zerofool/show-on-scroll';

const customTransition = makeTransition({
	start: {'opacity': '0'},
	end: {
		'opacity': '1'
		'transition': 'opacity 1s'
	}
});

showOnScroll('.boxes', customTransition);
```
At it's most basic a transition is an object with a start and and end state. Each state is an object where the keys are valid css properties (kebab-case) and the values are the css property values. Remember to include a transition property for the end state if you're defining your own transitions or states will switch without any animation.

## Staggering

SoS will automatically stagger transitioned elements as they come into view regardless of where they sit in the markup. It works responsively too.

## Style attributes

SoS adds css to the transitioned elements style attribute directly; it assumes it has your permission to do this...

## Documentation

Coming soon™

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