https://github.com/bttmly/shaker
A CoffeeScript class for, uh, shaking things
https://github.com/bttmly/shaker
Last synced: 3 months ago
JSON representation
A CoffeeScript class for, uh, shaking things
- Host: GitHub
- URL: https://github.com/bttmly/shaker
- Owner: bttmly
- Created: 2014-04-26T00:58:59.000Z (about 11 years ago)
- Default Branch: gh-pages
- Last Pushed: 2014-06-04T23:48:01.000Z (almost 11 years ago)
- Last Synced: 2025-01-08T22:00:00.793Z (4 months ago)
- Language: CoffeeScript
- Homepage: http://nickb1080.github.io/shaker/
- Size: 242 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Shaker
_A CoffeeScript class for, uh, shaking things._**Instantiation**
(default params shown)
```javascript
var shaker = new Shaker({
amount : 5, // intensity of the shake
shakes : 5, // number of shakes
animationName : "shaky-shaky", // name of the animation
className : "shaking-shaking", // name of the applied class
direction : "vertical", // or "horizontal"
duration : .5, // in seconds
multiplier : function( i, t ){
return ( t - i ) / t
}, // describes the shake amount at each increment. i = iteration, t = @shakes
// for reasonable looking shaking, function should produce declining values as i approaches t
flat : false // shaking in 3d is cooler anyway
concave : false // change at your own risk
});
```**Usage**
```javascript
shaker.shake( document.getElementById( "id" ), function( el ) {
// "this" is the shaker
});
```You can implement your own jQuery plugin, maybe like so (untested):
```javascript
$.fn.shakeWith = function( shaker, opts, cb) {
$( this ).each( function( e ) {
var args = [].slice.call( arguments );
args.shift();
args.unshift( e );
shaker.shake.apply( shaker, args );
});
};
```