Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krivega/request-animation
https://github.com/krivega/request-animation
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/krivega/request-animation
- Owner: Krivega
- License: mit
- Created: 2020-01-09T15:52:29.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T12:06:36.000Z (8 months ago)
- Last Synced: 2024-12-02T12:53:53.056Z (about 1 month ago)
- Language: TypeScript
- Size: 1.24 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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 effectrequestAnimation.activate();
requestAnimation.run(() => {
// some logic
}); // handler is called
```### requestAnimation.activate()
Enable call requests.
```js
requestAnimation.deactivate();
requestAnimation.run(() => {
// some logic
}); // no effectrequestAnimation.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.