jquery.ui.effect-slide.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. * jQuery UI Effects Slide v1.9 stable
  3. * http://jqueryui.com
  4. *
  5. * Copyright 2012 jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. *
  9. * http://api.jqueryui.com/slide-effect/
  10. *
  11. * Depends:
  12. * jquery.ui.effect.js
  13. */
  14. (function( $, undefined ) {
  15. $.effects.effect.slide = function( o, done ) {
  16. // Create element
  17. var el = $( this ),
  18. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  19. mode = $.effects.setMode( el, o.mode || "show" ),
  20. show = mode === "show",
  21. direction = o.direction || "left",
  22. ref = (direction === "up" || direction === "down") ? "top" : "left",
  23. positiveMotion = (direction === "up" || direction === "left"),
  24. distance,
  25. animation = {};
  26. // Adjust
  27. $.effects.save( el, props );
  28. el.show();
  29. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  30. $.effects.createWrapper( el ).css({
  31. overflow: "hidden"
  32. });
  33. if ( show ) {
  34. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  35. }
  36. // Animation
  37. animation[ ref ] = ( show ?
  38. ( positiveMotion ? "+=" : "-=") :
  39. ( positiveMotion ? "-=" : "+=")) +
  40. distance;
  41. // Animate
  42. el.animate( animation, {
  43. queue: false,
  44. duration: o.duration,
  45. easing: o.easing,
  46. complete: function() {
  47. if ( mode === "hide" ) {
  48. el.hide();
  49. }
  50. $.effects.restore( el, props );
  51. $.effects.removeWrapper( el );
  52. done();
  53. }
  54. });
  55. };
  56. })(jQuery);