Nessuna descrizione

effect-pulsate.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. //>>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. if ( typeof define === "function" && define.amd ) {
  16. // AMD. Register as an anonymous module.
  17. define( [
  18. "jquery",
  19. "./effect"
  20. ], factory );
  21. } else {
  22. // Browser globals
  23. factory( jQuery );
  24. }
  25. }( function( $ ) {
  26. return $.effects.define( "pulsate", "show", function( options, done ) {
  27. var element = $( this ),
  28. mode = options.mode,
  29. show = mode === "show",
  30. hide = mode === "hide",
  31. showhide = show || hide,
  32. // Showing or hiding leaves off the "last" animation
  33. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  34. duration = options.duration / anims,
  35. animateTo = 0,
  36. i = 1,
  37. queuelen = element.queue().length;
  38. if ( show || !element.is( ":visible" ) ) {
  39. element.css( "opacity", 0 ).show();
  40. animateTo = 1;
  41. }
  42. // Anims - 1 opacity "toggles"
  43. for ( ; i < anims; i++ ) {
  44. element.animate( { opacity: animateTo }, duration, options.easing );
  45. animateTo = 1 - animateTo;
  46. }
  47. element.animate( { opacity: animateTo }, duration, options.easing );
  48. element.queue( done );
  49. $.effects.unshift( element, queuelen, anims + 1 );
  50. } );
  51. } ) );