2 * jQuery UI Effects Pulsate 1.12.1
5 * Copyright jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
10 //>>label: Pulsate Effect
12 //>>description: Pulsates an element n times by changing the opacity to zero and back.
13 //>>docs: http://api.jqueryui.com/pulsate-effect/
14 //>>demos: http://jqueryui.com/effect/
16 ( function( factory ) {
17 if ( typeof define === "function" && define.amd ) {
19 // AMD. Register as an anonymous module.
32 return $.effects.define( "pulsate", "show", function( options, done ) {
33 var element = $( this ),
35 show = mode === "show",
36 hide = mode === "hide",
37 showhide = show || hide,
39 // Showing or hiding leaves off the "last" animation
40 anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
41 duration = options.duration / anims,
44 queuelen = element.queue().length;
46 if ( show || !element.is( ":visible" ) ) {
47 element.css( "opacity", 0 ).show();
51 // Anims - 1 opacity "toggles"
52 for ( ; i < anims; i++ ) {
53 element.animate( { opacity: animateTo }, duration, options.easing );
54 animateTo = 1 - animateTo;
57 element.animate( { opacity: animateTo }, duration, options.easing );
59 element.queue( done );
61 $.effects.unshift( element, queuelen, anims + 1 );