git clone https://github.com/Bazooo/fun-shaker.git
Upon release on npm
npm install fun-shaker
import { Shaker } from 'fun-shaker';
let shaker = new Shaker();
Adds a new object to the shaker
// Shaker object
shaker.add({
callback: my_callback, // Function with no argument to be called back on shake
name: 'my_callback_name', // (Optional) Unique name for the shaker object
interval: 3000 // (Optional) Interval before called on autoshake
});
// OR
shaker.add(my_callback, 3000, 'my_callback_name');
Removes an object at an index or with an unique name
// Remove at index
shaker.remove(3);
// OR
shaker.remove('my_callback_name');
Runs the next callback in the queue
Shakes automatically in intervals
Stops the autoshaker
Pauses the autoshaker
Resumes the autoshaker
Rewinds the shaker by one
Get the number of objects left in the shaker
Get the index number of an object
shaker.getIndex('my_callback_name');
// => 3
- Mathieu Chan - Bazooo
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE file for details