effect-clip.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*!
  2. * jQuery UI Effects Clip 1.14.1
  3. * https://jqueryui.com
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license.
  7. * https://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: https://api.jqueryui.com/clip-effect/
  13. //>>demos: https://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. "../version",
  21. "../effect"
  22. ], factory );
  23. } else {
  24. // Browser globals
  25. factory( jQuery );
  26. }
  27. } )( function( $ ) {
  28. "use strict";
  29. return $.effects.define( "clip", "hide", function( options, done ) {
  30. var start,
  31. animate = {},
  32. element = $( this ),
  33. direction = options.direction || "vertical",
  34. both = direction === "both",
  35. horizontal = both || direction === "horizontal",
  36. vertical = both || direction === "vertical";
  37. start = element.cssClip();
  38. animate.clip = {
  39. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  40. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  41. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  42. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  43. };
  44. $.effects.createPlaceholder( element );
  45. if ( options.mode === "show" ) {
  46. element.cssClip( animate.clip );
  47. animate.clip = start;
  48. }
  49. element.animate( animate, {
  50. queue: false,
  51. duration: options.duration,
  52. easing: options.easing,
  53. complete: done
  54. } );
  55. } );
  56. } );