Skip to content

Instantly share code, notes, and snippets.

@khmyznikov
Created December 9, 2013 05:11
Show Gist options
  • Save khmyznikov/7867641 to your computer and use it in GitHub Desktop.
Save khmyznikov/7867641 to your computer and use it in GitHub Desktop.
jQuery.fn.shake = function(intShakes, intDistance, intDuration) {
this.each(function() {
$(this).css("position","relative");
for (var x=1; x<=intShakes; x++) {
$(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
.animate({left:intDistance}, ((intDuration/intShakes)/2))
.animate({left:0}, (((intDuration/intShakes)/4)));
}
});
return this;
};
$("#shaker").click(function(){
$("#shaker").shake(3,7,800);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment