Aucune description

effect-clip.js 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. * jQuery UI Effects Clip 1.12.1
  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. if ( typeof define === "function" && define.amd ) {
  16. // AMD. Register as an anonymous module.
  17. define( [
  18. "jquery",
  19. "./effect"
  20. ], factory );
  21. } else {
  22. // Browser globals
  23. factory( jQuery );
  24. }
  25. }( function( $ ) {
  26. return $.effects.define( "clip", "hide", function( options, done ) {
  27. var start,
  28. animate = {},
  29. element = $( this ),
  30. direction = options.direction || "vertical",
  31. both = direction === "both",
  32. horizontal = both || direction === "horizontal",
  33. vertical = both || direction === "vertical";
  34. start = element.cssClip();
  35. animate.clip = {
  36. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  37. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  38. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  39. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  40. };
  41. $.effects.createPlaceholder( element );
  42. if ( options.mode === "show" ) {
  43. element.cssClip( animate.clip );
  44. animate.clip = start;
  45. }
  46. element.animate( animate, {
  47. queue: false,
  48. duration: options.duration,
  49. easing: options.easing,
  50. complete: done
  51. } );
  52. } );
  53. } ) );