2020-10-07 12:33:25 -04:00
|
|
|
/*!
|
2024-05-27 17:14:15 -04:00
|
|
|
* jQuery UI Effects Shake 1.13.3
|
|
|
|
* https://jqueryui.com
|
2020-10-07 12:33:25 -04:00
|
|
|
*
|
2024-05-27 17:14:15 -04:00
|
|
|
* Copyright OpenJS Foundation and other contributors
|
2020-10-07 12:33:25 -04:00
|
|
|
* Released under the MIT license.
|
2024-05-27 17:14:15 -04:00
|
|
|
* https://jquery.org/license
|
2020-10-07 12:33:25 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
//>>label: Shake Effect
|
|
|
|
//>>group: Effects
|
|
|
|
//>>description: Shakes an element horizontally or vertically n times.
|
2024-05-27 17:14:15 -04:00
|
|
|
//>>docs: https://api.jqueryui.com/shake-effect/
|
|
|
|
//>>demos: https://jqueryui.com/effect/
|
2020-10-07 12:33:25 -04:00
|
|
|
|
|
|
|
( function( factory ) {
|
2021-09-09 20:02:59 -04:00
|
|
|
"use strict";
|
|
|
|
|
2020-10-07 12:33:25 -04:00
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
|
|
|
|
|
|
// AMD. Register as an anonymous module.
|
|
|
|
define( [
|
|
|
|
"jquery",
|
2024-05-27 17:14:15 -04:00
|
|
|
"../version",
|
|
|
|
"../effect"
|
2020-10-07 12:33:25 -04:00
|
|
|
], factory );
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Browser globals
|
|
|
|
factory( jQuery );
|
|
|
|
}
|
2021-09-09 20:02:59 -04:00
|
|
|
} )( function( $ ) {
|
|
|
|
"use strict";
|
2020-10-07 12:33:25 -04:00
|
|
|
|
|
|
|
return $.effects.define( "shake", function( options, done ) {
|
|
|
|
|
|
|
|
var i = 1,
|
|
|
|
element = $( this ),
|
|
|
|
direction = options.direction || "left",
|
|
|
|
distance = options.distance || 20,
|
|
|
|
times = options.times || 3,
|
|
|
|
anims = times * 2 + 1,
|
|
|
|
speed = Math.round( options.duration / anims ),
|
|
|
|
ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
|
|
|
|
positiveMotion = ( direction === "up" || direction === "left" ),
|
|
|
|
animation = {},
|
|
|
|
animation1 = {},
|
|
|
|
animation2 = {},
|
|
|
|
|
|
|
|
queuelen = element.queue().length;
|
|
|
|
|
|
|
|
$.effects.createPlaceholder( element );
|
|
|
|
|
|
|
|
// Animation
|
|
|
|
animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
|
|
|
|
animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
|
|
|
|
animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
|
|
|
|
|
|
|
|
// Animate
|
|
|
|
element.animate( animation, speed, options.easing );
|
|
|
|
|
|
|
|
// Shakes
|
|
|
|
for ( ; i < times; i++ ) {
|
|
|
|
element
|
|
|
|
.animate( animation1, speed, options.easing )
|
|
|
|
.animate( animation2, speed, options.easing );
|
|
|
|
}
|
|
|
|
|
|
|
|
element
|
|
|
|
.animate( animation1, speed, options.easing )
|
|
|
|
.animate( animation, speed / 2, options.easing )
|
|
|
|
.queue( done );
|
|
|
|
|
|
|
|
$.effects.unshift( element, queuelen, anims + 1 );
|
|
|
|
} );
|
|
|
|
|
2021-09-09 20:02:59 -04:00
|
|
|
} );
|