Няма описание

effect-slide.js 1.9KB

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