effects.blind.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * jQuery UI Effects Blind 1.7.2
  3. *
  4. * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
  5. * Dual licensed under the MIT (MIT-LICENSE.txt)
  6. * and GPL (GPL-LICENSE.txt) licenses.
  7. *
  8. * http://docs.jquery.com/UI/Effects/Blind
  9. *
  10. * Depends:
  11. * effects.core.js
  12. */
  13. (function($) {
  14. $.effects.blind = function(o) {
  15. return this.queue(function() {
  16. // Create element
  17. var el = $(this), props = ['position','top','left'];
  18. // Set options
  19. var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
  20. var direction = o.options.direction || 'vertical'; // Default direction
  21. // Adjust
  22. $.effects.save(el, props); el.show(); // Save & Show
  23. var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
  24. var ref = (direction == 'vertical') ? 'height' : 'width';
  25. var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
  26. if(mode == 'show') wrapper.css(ref, 0); // Shift
  27. // Animation
  28. var animation = {};
  29. animation[ref] = mode == 'show' ? distance : 0;
  30. // Animate
  31. wrapper.animate(animation, o.duration, o.options.easing, function() {
  32. if(mode == 'hide') el.hide(); // Hide
  33. $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
  34. if(o.callback) o.callback.apply(el[0], arguments); // Callback
  35. el.dequeue();
  36. });
  37. });
  38. };
  39. })(jQuery);