https://github.com/drawcall/rafmanager
🌒🌓🌔🌕🌖🌗🌘 Only 1kb simple requestAnimationFrame animation manager
https://github.com/drawcall/rafmanager
1k 1kb raf requestanimationframe
Last synced: about 1 month ago
JSON representation
🌒🌓🌔🌕🌖🌗🌘 Only 1kb simple requestAnimationFrame animation manager
- Host: GitHub
- URL: https://github.com/drawcall/rafmanager
- Owner: drawcall
- License: mit
- Created: 2018-12-03T05:34:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-01-27T06:18:36.000Z (4 months ago)
- Last Synced: 2025-03-31T01:23:55.766Z (2 months ago)
- Topics: 1k, 1kb, raf, requestanimationframe
- Language: JavaScript
- Homepage:
- Size: 87.9 KB
- Stars: 18
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RAFManager

## Overview
**RAFManager** is a lightweight and efficient animation manager built on top of the `requestAnimationFrame` API. It provides precise global control over the addition and removal of animations.
### Key Features
- **Minimalistic**: Implemented in just a few dozen lines of code
- **Easy Integration**: Use as a foundation for animation projects or integrate where needed
- **Global Control**: Effortlessly manage animations across your entire application## Installation
### Browser
Include the script directly in your HTML file:
```html
```
### npm
Install using npm:
```bash
npm install raf-manager --save
```Then import it in your project:
```javascript
import RAFManager from 'raf-manager';
```## API
### Add an Animation Function - Auto Start
```javascript
RAFManager.add(func, fps, param);
```### Remove an Animation Function - Auto Stop
```javascript
RAFManager.remove(func);
```### Force Start and Stop
```javascript
RAFManager.start();
RAFManager.stop();
```## Usage Demo
```javascript
RAFManager.add((title) => {
top++;
const node = this.inputRef.current;
node.innerHTML = title;
node.style.top = top + 'px';
}, 25, 'hello world!');
``````javascript
RAFManager.add(func1, 2);
RAFManager.add(func2, 3.5);
RAFManager.add(func3, 10.5);
```## Build
Node.js is a dependency. Use the terminal to install it with npm:
```bash
npm install
npm run build
```### ES6 Lint
```bash
npm run lint
```## License
RAFManager is released under the MIT License. [http://www.opensource.org/licenses/mit-license](http://www.opensource.org/licenses/mit-license)