request-animation-runner
v1.0.1
Published
Class for run loop animation with RAF
Downloads
1,586
Readme
request-animation-runner
Class for run loop animation with RAF
Install
npm
npm install request-animation-runner
yarn
yarn add request-animation-runner
Usage
import RequestAnimation from 'request-animation-runner';
const requestAnimation = new RequestAnimation();
requestAnimation.activate();
requestAnimation.run(() => {
// some logic
});
API
requestAnimation.deactivate()
Disable call requests.
requestAnimation.deactivate();
requestAnimation.run(() => {
// some logic
}); // no effect
requestAnimation.activate();
requestAnimation.run(() => {
// some logic
}); // handler is called
requestAnimation.activate()
Enable call requests.
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}
requestAnimation.run(() => {
// some logic
});
requestAnimation.request
Request single call.
@param {function} animationFunc - Function for animation
@returns {undefined}
requestAnimation.request(() => {
// some logic
});
requestAnimation.cancelRequest
Cancel current request.
- @returns {undefined}
requestAnimation.cancelRequest();
Run tests
npm test
Maintainer
Krivega Dmitriy
- Website: https://krivega.com
- Github: @Krivega
Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
📝 License
Copyright © 2020 Krivega Dmitriy. This project is MIT licensed.