2 * jQuery UI Effects Shake 1.9.2
5 * Copyright 2012 jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
9 * http://api.jqueryui.com/shake-effect/
14 (function( $, undefined ) {
16 $.effects.effect.shake = function( o, done ) {
19 props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
20 mode = $.effects.setMode( el, o.mode || "effect" ),
21 direction = o.direction || "left",
22 distance = o.distance || 20,
24 anims = times * 2 + 1,
25 speed = Math.round(o.duration/anims),
26 ref = (direction === "up" || direction === "down") ? "top" : "left",
27 positiveMotion = (direction === "up" || direction === "left"),
33 // we will need to re-assemble the queue to stack our animations in place
35 queuelen = queue.length;
37 $.effects.save( el, props );
39 $.effects.createWrapper( el );
42 animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
43 animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
44 animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
47 el.animate( animation, speed, o.easing );
50 for ( i = 1; i < times; i++ ) {
51 el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
54 .animate( animation1, speed, o.easing )
55 .animate( animation, speed / 2, o.easing )
57 if ( mode === "hide" ) {
60 $.effects.restore( el, props );
61 $.effects.removeWrapper( el );
65 // inject all the animations we just queued to be first in line (after "inprogress")
67 queue.splice.apply( queue,
68 [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );