Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/krivega/request-animation


https://github.com/krivega/request-animation

Last synced: 26 days ago
JSON representation

Awesome Lists containing this project

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!
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).

This project is [MIT](https://github.com/Krivega/request-animation/blob/master/LICENSE) licensed.