effect-clip.js 1.6 KB

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