|
1 /*! |
|
2 * jQuery UI Effects Pulsate 1.12.1 |
|
3 * http://jqueryui.com |
|
4 * |
|
5 * Copyright jQuery Foundation and other contributors |
|
6 * Released under the MIT license. |
|
7 * http://jquery.org/license |
|
8 */ |
|
9 |
|
10 //>>label: Pulsate Effect |
|
11 //>>group: Effects |
|
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/ |
|
15 |
|
16 ( function( factory ) { |
|
17 if ( typeof define === "function" && define.amd ) { |
|
18 |
|
19 // AMD. Register as an anonymous module. |
|
20 define( [ |
|
21 "jquery", |
|
22 "./effect" |
|
23 ], factory ); |
|
24 } else { |
|
25 |
|
26 // Browser globals |
|
27 factory( jQuery ); |
|
28 } |
|
29 }( function( $ ) { |
|
30 |
|
31 return $.effects.define( "pulsate", "show", function( options, done ) { |
|
32 var element = $( this ), |
|
33 mode = options.mode, |
|
34 show = mode === "show", |
|
35 hide = mode === "hide", |
|
36 showhide = show || hide, |
|
37 |
|
38 // Showing or hiding leaves off the "last" animation |
|
39 anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), |
|
40 duration = options.duration / anims, |
|
41 animateTo = 0, |
|
42 i = 1, |
|
43 queuelen = element.queue().length; |
|
44 |
|
45 if ( show || !element.is( ":visible" ) ) { |
|
46 element.css( "opacity", 0 ).show(); |
|
47 animateTo = 1; |
|
48 } |
|
49 |
|
50 // Anims - 1 opacity "toggles" |
|
51 for ( ; i < anims; i++ ) { |
|
52 element.animate( { opacity: animateTo }, duration, options.easing ); |
|
53 animateTo = 1 - animateTo; |
|
54 } |
|
55 |
|
56 element.animate( { opacity: animateTo }, duration, options.easing ); |
|
57 |
|
58 element.queue( done ); |
|
59 |
|
60 $.effects.unshift( element, queuelen, anims + 1 ); |
|
61 } ); |
|
62 |
|
63 } ) ); |