1
0

effect-blind.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*!
  2. * jQuery UI Effects Blind 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/blind-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.blind = function( o, done ) {
  24. // Create element
  25. var el = $( this ),
  26. rvertical = /up|down|vertical/,
  27. rpositivemotion = /up|left|vertical|horizontal/,
  28. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  29. mode = $.effects.setMode( el, o.mode || "hide" ),
  30. direction = o.direction || "up",
  31. vertical = rvertical.test( direction ),
  32. ref = vertical ? "height" : "width",
  33. ref2 = vertical ? "top" : "left",
  34. motion = rpositivemotion.test( direction ),
  35. animation = {},
  36. show = mode === "show",
  37. wrapper, distance, margin;
  38. // if already wrapped, the wrapper's properties are my property. #6245
  39. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  40. $.effects.save( el.parent(), props );
  41. } else {
  42. $.effects.save( el, props );
  43. }
  44. el.show();
  45. wrapper = $.effects.createWrapper( el ).css({
  46. overflow: "hidden"
  47. });
  48. distance = wrapper[ ref ]();
  49. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  50. animation[ ref ] = show ? distance : 0;
  51. if ( !motion ) {
  52. el
  53. .css( vertical ? "bottom" : "right", 0 )
  54. .css( vertical ? "top" : "left", "auto" )
  55. .css({ position: "absolute" });
  56. animation[ ref2 ] = show ? margin : distance + margin;
  57. }
  58. // start at 0 if we are showing
  59. if ( show ) {
  60. wrapper.css( ref, 0 );
  61. if ( !motion ) {
  62. wrapper.css( ref2, margin + distance );
  63. }
  64. }
  65. // Animate
  66. wrapper.animate( animation, {
  67. duration: o.duration,
  68. easing: o.easing,
  69. queue: false,
  70. complete: function() {
  71. if ( mode === "hide" ) {
  72. el.hide();
  73. }
  74. $.effects.restore( el, props );
  75. $.effects.removeWrapper( el );
  76. done();
  77. }
  78. });
  79. };
  80. }));