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.

91 lines
2.1 KiB

1 year ago
  1. /*!
  2. * jQuery UI Effects Fold 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: Fold Effect
  10. //>>group: Effects
  11. //>>description: Folds an element first horizontally and then vertically.
  12. //>>docs: http://api.jqueryui.com/fold-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( "fold", "hide", function( options, done ) {
  29. // Create element
  30. var element = $( this ),
  31. mode = options.mode,
  32. show = mode === "show",
  33. hide = mode === "hide",
  34. size = options.size || 15,
  35. percent = /([0-9]+)%/.exec( size ),
  36. horizFirst = !!options.horizFirst,
  37. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  38. duration = options.duration / 2,
  39. placeholder = $.effects.createPlaceholder( element ),
  40. start = element.cssClip(),
  41. animation1 = { clip: $.extend( {}, start ) },
  42. animation2 = { clip: $.extend( {}, start ) },
  43. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  44. queuelen = element.queue().length;
  45. if ( percent ) {
  46. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  47. }
  48. animation1.clip[ ref[ 0 ] ] = size;
  49. animation2.clip[ ref[ 0 ] ] = size;
  50. animation2.clip[ ref[ 1 ] ] = 0;
  51. if ( show ) {
  52. element.cssClip( animation2.clip );
  53. if ( placeholder ) {
  54. placeholder.css( $.effects.clipToBox( animation2 ) );
  55. }
  56. animation2.clip = start;
  57. }
  58. // Animate
  59. element
  60. .queue( function( next ) {
  61. if ( placeholder ) {
  62. placeholder
  63. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  64. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  65. }
  66. next();
  67. } )
  68. .animate( animation1, duration, options.easing )
  69. .animate( animation2, duration, options.easing )
  70. .queue( done );
  71. $.effects.unshift( element, queuelen, 4 );
  72. } );
  73. } );