You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5 KiB

1 year ago
  1. /*!
  2. * jQuery UI Effects Pulsate 1.13.2
  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. //>>label: Pulsate Effect
  10. //>>group: Effects
  11. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  12. //>>docs: http://api.jqueryui.com/pulsate-effect/
  13. //>>demos: http://jqueryui.com/effect/
  14. ( function( factory ) {
  15. "use strict";
  16. if ( typeof define === "function" && define.amd ) {
  17. // AMD. Register as an anonymous module.
  18. define( [
  19. "jquery",
  20. "./effect"
  21. ], factory );
  22. } else {
  23. // Browser globals
  24. factory( jQuery );
  25. }
  26. } )( function( $ ) {
  27. "use strict";
  28. return $.effects.define( "pulsate", "show", function( options, done ) {
  29. var element = $( this ),
  30. mode = options.mode,
  31. show = mode === "show",
  32. hide = mode === "hide",
  33. showhide = show || hide,
  34. // Showing or hiding leaves off the "last" animation
  35. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  36. duration = options.duration / anims,
  37. animateTo = 0,
  38. i = 1,
  39. queuelen = element.queue().length;
  40. if ( show || !element.is( ":visible" ) ) {
  41. element.css( "opacity", 0 ).show();
  42. animateTo = 1;
  43. }
  44. // Anims - 1 opacity "toggles"
  45. for ( ; i < anims; i++ ) {
  46. element.animate( { opacity: animateTo }, duration, options.easing );
  47. animateTo = 1 - animateTo;
  48. }
  49. element.animate( { opacity: animateTo }, duration, options.easing );
  50. element.queue( done );
  51. $.effects.unshift( element, queuelen, anims + 1 );
  52. } );
  53. } );