effect-clip.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*!
  2. * jQuery UI Effects Clip 1.13.2
  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. //>>label: Clip Effect
  10. //>>group: Effects
  11. //>>description: Clips the element on and off like an old TV.
  12. //>>docs: http://api.jqueryui.com/clip-effect/
  13. //>>demos: http://jqueryui.com/effect/
  14. ( function( factory ) {
  15. "use strict";
  16. if ( typeof define === "function" && define.amd ) {
  17. // AMD. Register as an anonymous module.
  18. define( [
  19. "jquery",
  20. "./effect"
  21. ], factory );
  22. } else {
  23. // Browser globals
  24. factory( jQuery );
  25. }
  26. } )( function( $ ) {
  27. "use strict";
  28. return $.effects.define( "clip", "hide", function( options, done ) {
  29. var start,
  30. animate = {},
  31. element = $( this ),
  32. direction = options.direction || "vertical",
  33. both = direction === "both",
  34. horizontal = both || direction === "horizontal",
  35. vertical = both || direction === "vertical";
  36. start = element.cssClip();
  37. animate.clip = {
  38. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  39. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  40. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  41. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  42. };
  43. $.effects.createPlaceholder( element );
  44. if ( options.mode === "show" ) {
  45. element.cssClip( animate.clip );
  46. animate.clip = start;
  47. }
  48. element.animate( animate, {
  49. queue: false,
  50. duration: options.duration,
  51. easing: options.easing,
  52. complete: done
  53. } );
  54. } );
  55. } );