[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/jquery/ui/ -> effect-fold.js (source)

   1  /*!
   2   * jQuery UI Effects Fold 1.13.3
   3   * https://jqueryui.com
   4   *
   5   * Copyright OpenJS Foundation and other contributors
   6   * Released under the MIT license.
   7   * https://jquery.org/license
   8   */
   9  
  10  //>>label: Fold Effect
  11  //>>group: Effects
  12  //>>description: Folds an element first horizontally and then vertically.
  13  //>>docs: https://api.jqueryui.com/fold-effect/
  14  //>>demos: https://jqueryui.com/effect/
  15  
  16  ( function( factory ) {
  17      "use strict";
  18  
  19      if ( typeof define === "function" && define.amd ) {
  20  
  21          // AMD. Register as an anonymous module.
  22          define( [
  23              "jquery",
  24              "../version",
  25              "../effect"
  26          ], factory );
  27      } else {
  28  
  29          // Browser globals
  30          factory( jQuery );
  31      }
  32  } )( function( $ ) {
  33  "use strict";
  34  
  35  return $.effects.define( "fold", "hide", function( options, done ) {
  36  
  37      // Create element
  38      var element = $( this ),
  39          mode = options.mode,
  40          show = mode === "show",
  41          hide = mode === "hide",
  42          size = options.size || 15,
  43          percent = /([0-9]+)%/.exec( size ),
  44          horizFirst = !!options.horizFirst,
  45          ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  46          duration = options.duration / 2,
  47  
  48          placeholder = $.effects.createPlaceholder( element ),
  49  
  50          start = element.cssClip(),
  51          animation1 = { clip: $.extend( {}, start ) },
  52          animation2 = { clip: $.extend( {}, start ) },
  53  
  54          distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  55  
  56          queuelen = element.queue().length;
  57  
  58      if ( percent ) {
  59          size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  60      }
  61      animation1.clip[ ref[ 0 ] ] = size;
  62      animation2.clip[ ref[ 0 ] ] = size;
  63      animation2.clip[ ref[ 1 ] ] = 0;
  64  
  65      if ( show ) {
  66          element.cssClip( animation2.clip );
  67          if ( placeholder ) {
  68              placeholder.css( $.effects.clipToBox( animation2 ) );
  69          }
  70  
  71          animation2.clip = start;
  72      }
  73  
  74      // Animate
  75      element
  76          .queue( function( next ) {
  77              if ( placeholder ) {
  78                  placeholder
  79                      .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  80                      .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  81              }
  82  
  83              next();
  84          } )
  85          .animate( animation1, duration, options.easing )
  86          .animate( animation2, duration, options.easing )
  87          .queue( done );
  88  
  89      $.effects.unshift( element, queuelen, 4 );
  90  } );
  91  
  92  } );


Generated : Fri Nov 15 08:20:01 2024 Cross-referenced by PHPXref