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.

71 lines
1.5 KiB

1 year ago
  1. /*!
  2. * jQuery UI Effects Drop 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: Drop Effect
  10. //>>group: Effects
  11. //>>description: Moves an element in one direction and hides it at the same time.
  12. //>>docs: http://api.jqueryui.com/drop-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( "drop", "hide", function( options, done ) {
  29. var distance,
  30. element = $( this ),
  31. mode = options.mode,
  32. show = mode === "show",
  33. direction = options.direction || "left",
  34. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  35. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  36. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  37. animation = {
  38. opacity: 0
  39. };
  40. $.effects.createPlaceholder( element );
  41. distance = options.distance ||
  42. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  43. animation[ ref ] = motion + distance;
  44. if ( show ) {
  45. element.css( animation );
  46. animation[ ref ] = oppositeMotion + distance;
  47. animation.opacity = 1;
  48. }
  49. // Animate
  50. element.animate( animation, {
  51. queue: false,
  52. duration: options.duration,
  53. easing: options.easing,
  54. complete: done
  55. } );
  56. } );
  57. } );