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

effect-fold.js 2.1KB

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