2016-08-10 21:36:11 +02:00
|
|
|
/**
|
|
|
|
* jQuery prototype extensions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2016-07-07 23:23:18 +02:00
|
|
|
/**
|
|
|
|
* Shake animation.
|
|
|
|
*
|
|
|
|
* @param intShakes Number of times to shake.
|
|
|
|
* @param intDistance Distance to move the object.
|
|
|
|
* @param intDuration Duration of the animation.
|
2016-08-10 21:36:11 +02:00
|
|
|
*
|
|
|
|
* @return The element it was applied one, for chaining.
|
2016-07-07 23:23:18 +02:00
|
|
|
*/
|
2016-08-10 23:50:23 +02:00
|
|
|
$.fn.shake = function (intShakes, intDistance, intDuration) {
|
|
|
|
this.each(function () {
|
2016-07-07 23:23:18 +02:00
|
|
|
$(this).css("position","relative");
|
2016-08-03 15:44:29 +02:00
|
|
|
for (let x=1; x<=intShakes; x++) {
|
2016-07-07 23:23:18 +02:00
|
|
|
$(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
|
|
|
|
.animate({left:intDistance}, ((intDuration/intShakes)/2))
|
|
|
|
.animate({left:0}, (((intDuration/intShakes)/4)));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
};
|