wp/wp-includes/js/jquery/ui/effect-drop.js
changeset 18 be944660c56a
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
       
     1 /*!
       
     2  * jQuery UI Effects Drop 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 
       
    10 //>>label: Drop Effect
       
    11 //>>group: Effects
       
    12 //>>description: Moves an element in one direction and hides it at the same time.
       
    13 //>>docs: http://api.jqueryui.com/drop-effect/
       
    14 //>>demos: http://jqueryui.com/effect/
       
    15 
       
    16 ( function( factory ) {
       
    17 	if ( typeof define === "function" && define.amd ) {
       
    18 
       
    19 		// AMD. Register as an anonymous module.
       
    20 		define( [
       
    21 			"jquery",
       
    22 			"./effect"
       
    23 		], factory );
       
    24 	} else {
       
    25 
       
    26 		// Browser globals
       
    27 		factory( jQuery );
       
    28 	}
       
    29 }( function( $ ) {
       
    30 
       
    31 return $.effects.define( "drop", "hide", function( options, done ) {
       
    32 
       
    33 	var distance,
       
    34 		element = $( this ),
       
    35 		mode = options.mode,
       
    36 		show = mode === "show",
       
    37 		direction = options.direction || "left",
       
    38 		ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
       
    39 		motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
       
    40 		oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
       
    41 		animation = {
       
    42 			opacity: 0
       
    43 		};
       
    44 
       
    45 	$.effects.createPlaceholder( element );
       
    46 
       
    47 	distance = options.distance ||
       
    48 		element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
       
    49 
       
    50 	animation[ ref ] = motion + distance;
       
    51 
       
    52 	if ( show ) {
       
    53 		element.css( animation );
       
    54 
       
    55 		animation[ ref ] = oppositeMotion + distance;
       
    56 		animation.opacity = 1;
       
    57 	}
       
    58 
       
    59 	// Animate
       
    60 	element.animate( animation, {
       
    61 		queue: false,
       
    62 		duration: options.duration,
       
    63 		easing: options.easing,
       
    64 		complete: done
       
    65 	} );
       
    66 } );
       
    67 
       
    68 } ) );