mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
4966aea381
Also, update a few stale URLs to what they redirect now to. Closes gh-2244
68 lines
1.5 KiB
JavaScript
68 lines
1.5 KiB
JavaScript
/*!
|
|
* jQuery UI Effects Pulsate @VERSION
|
|
* https://jqueryui.com
|
|
*
|
|
* Copyright OpenJS Foundation and other contributors
|
|
* Released under the MIT license.
|
|
* https://jquery.org/license
|
|
*/
|
|
|
|
//>>label: Pulsate Effect
|
|
//>>group: Effects
|
|
//>>description: Pulsates an element n times by changing the opacity to zero and back.
|
|
//>>docs: https://api.jqueryui.com/pulsate-effect/
|
|
//>>demos: https://jqueryui.com/effect/
|
|
|
|
( function( factory ) {
|
|
"use strict";
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
|
|
// AMD. Register as an anonymous module.
|
|
define( [
|
|
"jquery",
|
|
"../version",
|
|
"../effect"
|
|
], factory );
|
|
} else {
|
|
|
|
// Browser globals
|
|
factory( jQuery );
|
|
}
|
|
} )( function( $ ) {
|
|
"use strict";
|
|
|
|
return $.effects.define( "pulsate", "show", function( options, done ) {
|
|
var element = $( this ),
|
|
mode = options.mode,
|
|
show = mode === "show",
|
|
hide = mode === "hide",
|
|
showhide = show || hide,
|
|
|
|
// Showing or hiding leaves off the "last" animation
|
|
anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
|
|
duration = options.duration / anims,
|
|
animateTo = 0,
|
|
i = 1,
|
|
queuelen = element.queue().length;
|
|
|
|
if ( show || !element.is( ":visible" ) ) {
|
|
element.css( "opacity", 0 ).show();
|
|
animateTo = 1;
|
|
}
|
|
|
|
// Anims - 1 opacity "toggles"
|
|
for ( ; i < anims; i++ ) {
|
|
element.animate( { opacity: animateTo }, duration, options.easing );
|
|
animateTo = 1 - animateTo;
|
|
}
|
|
|
|
element.animate( { opacity: animateTo }, duration, options.easing );
|
|
|
|
element.queue( done );
|
|
|
|
$.effects.unshift( element, queuelen, anims + 1 );
|
|
} );
|
|
|
|
} );
|