Skip to content

Instantly share code, notes, and snippets.

@kylefox
Created March 26, 2010 22:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kylefox/345491 to your computer and use it in GitHub Desktop.
Save kylefox/345491 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)), "swing")
.animate({left:intDistance}, ((intDuration/intShakes)/2), "swing")
.animate({left:0}, (((intDuration/intShakes)/4)), "swing");
}
});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment