jquery.ui.effect-clip.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*!
  2. * jQuery UI Effects Clip 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/clip-effect/
  10. *
  11. * Depends:
  12. * jquery.ui.effect.js
  13. */
  14. (function( $, undefined ) {
  15. $.effects.effect.clip = function( o, done ) {
  16. // Create element
  17. var el = $( this ),
  18. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  19. mode = $.effects.setMode( el, o.mode || "hide" ),
  20. show = mode === "show",
  21. direction = o.direction || "vertical",
  22. vert = direction === "vertical",
  23. size = vert ? "height" : "width",
  24. position = vert ? "top" : "left",
  25. animation = {},
  26. wrapper, animate, distance;
  27. // Save & Show
  28. $.effects.save( el, props );
  29. el.show();
  30. // Create Wrapper
  31. wrapper = $.effects.createWrapper( el ).css({
  32. overflow: "hidden"
  33. });
  34. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  35. distance = animate[ size ]();
  36. // Shift
  37. if ( show ) {
  38. animate.css( size, 0 );
  39. animate.css( position, distance / 2 );
  40. }
  41. // Create Animation Object:
  42. animation[ size ] = show ? distance : 0;
  43. animation[ position ] = show ? 0 : distance / 2;
  44. // Animate
  45. animate.animate( animation, {
  46. queue: false,
  47. duration: o.duration,
  48. easing: o.easing,
  49. complete: function() {
  50. if ( !show ) {
  51. el.hide();
  52. }
  53. $.effects.restore( el, props );
  54. $.effects.removeWrapper( el );
  55. done();
  56. }
  57. });
  58. };
  59. })(jQuery);