effect-blind.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. * jQuery UI Effects Blind 1.14.1
  3. * https://jqueryui.com
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license.
  7. * https://jquery.org/license
  8. */
  9. //>>label: Blind Effect
  10. //>>group: Effects
  11. //>>description: Blinds the element.
  12. //>>docs: https://api.jqueryui.com/blind-effect/
  13. //>>demos: https://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. "../version",
  21. "../effect"
  22. ], factory );
  23. } else {
  24. // Browser globals
  25. factory( jQuery );
  26. }
  27. } )( function( $ ) {
  28. "use strict";
  29. return $.effects.define( "blind", "hide", function( options, done ) {
  30. var map = {
  31. up: [ "bottom", "top" ],
  32. vertical: [ "bottom", "top" ],
  33. down: [ "top", "bottom" ],
  34. left: [ "right", "left" ],
  35. horizontal: [ "right", "left" ],
  36. right: [ "left", "right" ]
  37. },
  38. element = $( this ),
  39. direction = options.direction || "up",
  40. start = element.cssClip(),
  41. animate = { clip: $.extend( {}, start ) },
  42. placeholder = $.effects.createPlaceholder( element );
  43. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  44. if ( options.mode === "show" ) {
  45. element.cssClip( animate.clip );
  46. if ( placeholder ) {
  47. placeholder.css( $.effects.clipToBox( animate ) );
  48. }
  49. animate.clip = start;
  50. }
  51. if ( placeholder ) {
  52. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  53. }
  54. element.animate( animate, {
  55. queue: false,
  56. duration: options.duration,
  57. easing: options.easing,
  58. complete: done
  59. } );
  60. } );
  61. } );