# request-animation-runner

> Class for run loop animation with RAF

Latest version **1.0.1** (published 2024-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install request-animation-runner
pnpm add request-animation-runner
yarn add request-animation-runner
bun add request-animation-runner
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-05-21 |
| First published | 2020-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Krivega Dmitriy |
| Maintainers | krivega |
| Keywords | raf, animation |

## Links

- npm: https://www.npmjs.com/package/request-animation-runner
- Repository: https://github.com/Krivega/request-animation
- Homepage: https://github.com/Krivega/request-animation#readme
- Issues: https://github.com/Krivega/request-animation/issues
- npm.io page: https://npm.io/package/request-animation-runner

## 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.0.1 (latest) — 2024-05-21
- 1.0.0 — 2024-05-19
- 0.3.3 — 2022-12-30
- 0.3.2 — 2022-01-18
- 0.3.1 — 2021-04-08
- 0.3.0 — 2021-04-08
- 0.2.0 — 2021-04-08
- 0.1.0 — 2020-12-16
- 0.0.4 — 2020-03-31
- 0.0.3 — 2020-03-31
- 0.0.2 — 2020-01-13

## README

# request-animation-runner

[![npm](https://img.shields.io/npm/v/request-animation-runner?style=flat-square)](https://www.npmjs.com/package/request-animation-runner)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/request-animation-runner?style=flat-square)

Class for run loop animation with RAF

## Install

npm

```sh
npm install request-animation-runner
```

yarn

```sh
yarn add request-animation-runner
```

## Usage

```js
import RequestAnimation from 'request-animation-runner';

const requestAnimation = new RequestAnimation();

requestAnimation.activate();
requestAnimation.run(() => {
  // some logic
});
```

## API

### requestAnimation.deactivate()

Disable call requests.

```js
requestAnimation.deactivate();
requestAnimation.run(() => {
  // some logic
}); // no effect

requestAnimation.activate();
requestAnimation.run(() => {
  // some logic
}); // handler is called
```

### requestAnimation.activate()

Enable call requests.

```js
requestAnimation.deactivate();
requestAnimation.run(() => {
  // some logic
}); // no effect

requestAnimation.activate();
requestAnimation.run(() => {
  // some logic
}); // handler is called
```

### requestAnimation.run

Resolve the animation loop calculates time elapsed since the last loop and only draws if your specified fps interval is achieved.

- @param {function} animationFunc - Function for animation
- @param {string} fps - Frames per Second

- @returns {undefined}

```js
requestAnimation.run(() => {
  // some logic
});
```

### requestAnimation.request

Request single call.

- @param {function} animationFunc - Function for animation

- @returns {undefined}

```js
requestAnimation.request(() => {
  // some logic
});
```

### requestAnimation.cancelRequest

Cancel current request.

- @returns {undefined}

```js
requestAnimation.cancelRequest();
```

## Run tests

```sh
npm test
```

## Maintainer

**Krivega Dmitriy**

- Website: https://krivega.com
- Github: [@Krivega](https://github.com/Krivega)

## Contributing

Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/Krivega/request-animation/issues). You can also take a look at the [contributing guide](https://github.com/Krivega/request-animation/blob/master/CONTRIBUTING.md).

## 📝 License

Copyright © 2020 [Krivega Dmitriy](https://github.com/Krivega).<br />
This project is [MIT](https://github.com/Krivega/request-animation/blob/master/LICENSE) licensed.

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