You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.9 KiB

1 year ago
  1. /*!
  2. * jQuery UI Effects Slide 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: Slide Effect
  10. //>>group: Effects
  11. //>>description: Slides an element in and out of the viewport.
  12. //>>docs: http://api.jqueryui.com/slide-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( "slide", "show", function( options, done ) {
  29. var startClip, startRef,
  30. element = $( this ),
  31. map = {
  32. up: [ "bottom", "top" ],
  33. down: [ "top", "bottom" ],
  34. left: [ "right", "left" ],
  35. right: [ "left", "right" ]
  36. },
  37. mode = options.mode,
  38. direction = options.direction || "left",
  39. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  40. positiveMotion = ( direction === "up" || direction === "left" ),
  41. distance = options.distance ||
  42. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  43. animation = {};
  44. $.effects.createPlaceholder( element );
  45. startClip = element.cssClip();
  46. startRef = element.position()[ ref ];
  47. // Define hide animation
  48. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  49. animation.clip = element.cssClip();
  50. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  51. // Reverse the animation if we're showing
  52. if ( mode === "show" ) {
  53. element.cssClip( animation.clip );
  54. element.css( ref, animation[ ref ] );
  55. animation.clip = startClip;
  56. animation[ ref ] = startRef;
  57. }
  58. // Actually animate
  59. element.animate( animation, {
  60. queue: false,
  61. duration: options.duration,
  62. easing: options.easing,
  63. complete: done
  64. } );
  65. } );
  66. } );