blob: 2adb0d6d54af0b24bc1725b5c48a12cdcd163c4c [file] [log] [blame]
Thomas Vachuska0fa2aa12015-08-18 12:53:04 -07001/*
2jQuery Wiggle
3Author: WonderGroup, Jordan Thomas
4URL: http://labs.wondergroup.com/demos/mini-ui/index.html
5License: MIT (http://en.wikipedia.org/wiki/MIT_License)
6*/
7jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
8if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};