# raf-loop

> a minimal requestAnimationFrame render loop

Latest version **1.1.3** (published 2015-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install raf-loop
pnpm add raf-loop
yarn add raf-loop
bun add raf-loop
```

## 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.3 |
| Published | 2015-05-29 |
| First published | 2014-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | raf, request, animation, frame, requestAnimationFrame, loop, game, render, 2d |

## Links

- npm: https://www.npmjs.com/package/raf-loop
- Repository: https://github.com/mattdesl/raf-loop
- Issues: https://github.com/mattdesl/raf-loop/issues
- npm.io page: https://npm.io/package/raf-loop

## Dependencies (4)

- [raf](https://npm.io/package/raf.md) ^3.0.0
- [events](https://npm.io/package/events.md) ^1.0.2
- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [right-now](https://npm.io/package/right-now.md) ^1.0.0

## Alternatives

- [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
- [react-scroll-snap-anime-slider](https://npm.io/package/react-scroll-snap-anime-slider.md) — 214 weekly downloads

## Recent versions

- 1.1.3 (latest) — 2015-05-29
- 1.1.2 — 2015-05-24
- 1.1.1 — 2015-05-20
- 1.1.0 — 2015-05-09
- 1.0.1 — 2014-12-05
- 1.0.0 — 2014-12-05

## README

# raf-loop

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

A minimal requestAnimationFrame render loop for node and the browser, using high-performance timing where possible.

```js
var loop = require('raf-loop')

var engine = loop(function(dt) {
    // delta time in milliseconds 
}).start()
```

## Usage

[![NPM](https://nodei.co/npm/raf-loop.png)](https://nodei.co/npm/raf-loop/)

#### `engine = loop([fn])`

Creates a new loop with an optional function to receive tick events. The function will be called with delta time as the first parameter, in milliseconds.

#### `engine.start()`

Starts the render loop and returns this engine, for chaining.

#### `engine.stop()`

Stops the render loop and cancels the currently requested animation frame.

#### `engine.on('tick', fn)`

Attaches another function to the render loop.

## License

MIT, see [LICENSE.md](http://github.com/mattdesl/raf-loop/blob/master/LICENSE.md) for details.

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