# springs

> Super simple springs for custom animation

Latest version **1.1.0** (published 2017-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install springs
pnpm add springs
yarn add springs
bun add springs
```

## 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.1.0 |
| Published | 2017-08-04 |
| First published | 2017-03-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bruno Lourenco |
| Maintainers | brunnolou |
| Keywords | spring, animation, physics, springs |

## Links

- npm: https://www.npmjs.com/package/springs
- Repository: https://github.com/brunnolou/springs
- Homepage: https://github.com/brunnolou/springs#readme
- Issues: https://github.com/brunnolou/springs/issues
- npm.io page: https://npm.io/package/springs

## Dependencies (1)

- [rebound](https://npm.io/package/rebound.md) 0.0.13

## 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

- 1.1.0 (latest) — 2017-08-04
- 1.0.2 — 2017-08-02
- 1.0.1 — 2017-08-01
- 0.1.2 — 2017-03-17
- 0.1.1 — 2017-03-17
- 0.1.0 — 2017-03-17
- 0.0.1 — 2017-03-17

## README

# Springs
[![npm version](https://badge.fury.io/js/springs.svg)](https://badge.fury.io/js/springs)
![](https://david-dm.org/brunnolou/springs.svg)
![](https://img.shields.io/github/size/brunnolou/springs/lib/index.min.js.svg)

### Super simple springs animations.
Add real fluid physics to you custom javascript animations.

## Install
`npm install springs`

## Usage

Create the springs.
```js
import springs from 'springs';

// Tension, friction.
const s1 = springs(140, 10);
const s2 = springs(10, 1);
```


Then watch for example with `requestAnimationFrame`

```js
function update() {
  el.style.transform = `scale3d(${s1(x)}, ${s2(y)}, 0)`;

  requestAnimationFrame(update);
}

requestAnimationFrame(update);
```

Update the end value of the spring, in this case update `x` and `y` with mouse move.
```js
let x = 0;
let y = 0;

// Mouse move example.
function onMove({ clientX, clientY }) {
  x = clientX / 200;
  y = clientY / 200;
}

document.addEventListener('mousemove', onMove);
```

### Events

```js
springs(tension, friction, { events })
````
- `onInit`
- `onUpdate`
- `onActivate`
- `onRest`

### Defaults
```js
tension = 30,
friction = 1,
```

## Development
`npm install`

## Demo

`npm start`

`./example/` folder will be running on: `http://localhost:5000`

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