1
0

effect-pulsate.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. * jQuery UI Effects Pulsate 1.11.4
  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. * http://api.jqueryui.com/pulsate-effect/
  10. */
  11. (function( factory ) {
  12. if ( typeof define === "function" && define.amd ) {
  13. // AMD. Register as an anonymous module.
  14. define([
  15. "jquery",
  16. "./effect"
  17. ], factory );
  18. } else {
  19. // Browser globals
  20. factory( jQuery );
  21. }
  22. }(function( $ ) {
  23. return $.effects.effect.pulsate = function( o, done ) {
  24. var elem = $( this ),
  25. mode = $.effects.setMode( elem, o.mode || "show" ),
  26. show = mode === "show",
  27. hide = mode === "hide",
  28. showhide = ( show || mode === "hide" ),
  29. // showing or hiding leaves of the "last" animation
  30. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  31. duration = o.duration / anims,
  32. animateTo = 0,
  33. queue = elem.queue(),
  34. queuelen = queue.length,
  35. i;
  36. if ( show || !elem.is(":visible")) {
  37. elem.css( "opacity", 0 ).show();
  38. animateTo = 1;
  39. }
  40. // anims - 1 opacity "toggles"
  41. for ( i = 1; i < anims; i++ ) {
  42. elem.animate({
  43. opacity: animateTo
  44. }, duration, o.easing );
  45. animateTo = 1 - animateTo;
  46. }
  47. elem.animate({
  48. opacity: animateTo
  49. }, duration, o.easing);
  50. elem.queue(function() {
  51. if ( hide ) {
  52. elem.hide();
  53. }
  54. done();
  55. });
  56. // We just queued up "anims" animations, we need to put them next in the queue
  57. if ( queuelen > 1 ) {
  58. queue.splice.apply( queue,
  59. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  60. }
  61. elem.dequeue();
  62. };
  63. }));