jquery-ui/ui/jquery.effects.drop.js

65 lines
1.6 KiB
JavaScript
Raw Normal View History

/*
* jQuery UI Effects Drop @VERSION
*
2011-01-17 14:13:18 +00:00
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Effects/Drop
*
* Depends:
* jquery.effects.core.js
*/
(function( $, undefined ) {
2008-06-04 02:34:33 +00:00
$.effects.effect.drop = function( o ) {
2011-03-06 11:36:06 +00:00
return this.queue( function() {
var el = $( this ),
2011-03-06 11:36:06 +00:00
props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity' ],
mode = $.effects.setMode( el, o.mode || 'hide' ),
direction = o.direction || 'left',
ref = ( direction == 'up' || direction == 'down' ) ? 'top' : 'left',
motion = ( direction == 'up' || direction == 'left' ) ? 'pos' : 'neg',
2011-03-06 11:36:06 +00:00
animation = {
opacity: mode == 'show' ? 1 : 0
},
distance;
// Adjust
$.effects.save( el, props );
el.show();
$.effects.createWrapper( el );
2011-03-06 11:36:06 +00:00
distance = o.distance || el[ ref == 'top' ? 'outerHeight': 'outerWidth' ]({ margin: true }) / 2;
if ( mode == 'show' ) {
el
.css( 'opacity', 0 )
.css( ref, motion == 'pos' ? -distance : distance );
}
// Animation
2011-03-06 11:36:06 +00:00
animation[ ref ] = ((mode == 'show') ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
// Animate
2011-03-06 11:36:06 +00:00
el.animate( animation, {
queue: false,
duration: o.duration,
easing: o.easing,
complete: function() {
mode == 'hide' && el.hide();
2011-03-07 00:48:14 +00:00
$.effects.restore( el, props );
$.effects.removeWrapper( el );
2011-03-06 11:36:06 +00:00
$.isFunction( o.complete ) && o.complete.apply(this, arguments);
el.dequeue();
}
});
});
};
2008-06-04 02:34:33 +00:00
})(jQuery);