aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.effects.slide.js
diff options
context:
space:
mode:
authorgnarf <gnarf@gnarf.net>2011-03-06 18:34:18 -0600
committergnarf <gnarf@gnarf.net>2011-03-06 18:34:18 -0600
commit9c771b8f8b49a95da2b2234fdc0bd19c26a91038 (patch)
tree08a5bbddaeeb274b64d8e8ee0a94643dbf418cca /ui/jquery.effects.slide.js
parent7a60bc6824227bc2613eec1b79bcd6e8170d61f0 (diff)
downloadjquery-ui-9c771b8f8b49a95da2b2234fdc0bd19c26a91038.tar.gz
jquery-ui-9c771b8f8b49a95da2b2234fdc0bd19c26a91038.zip
effects.*: Style Guidance
Diffstat (limited to 'ui/jquery.effects.slide.js')
-rw-r--r--ui/jquery.effects.slide.js61
1 files changed, 40 insertions, 21 deletions
diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js
index 57b60290e..eeba117cf 100644
--- a/ui/jquery.effects.slide.js
+++ b/ui/jquery.effects.slide.js
@@ -12,36 +12,55 @@
*/
(function( $, undefined ) {
-$.effects.slide = function(o) {
+$.effects.slide = function( o ) {
- return this.queue(function() {
+ return this.queue( function() {
// Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.mode || 'show'); // Set Mode
- var direction = o.direction || 'left'; // Default Direction
+ var el = $( this ),
+ props = ['position','top','bottom','left','right'],
+ mode = $.effects.setMode( el, o.mode || 'show' ),
+ direction = o.direction || 'left',
+ ref = (direction == 'up' || direction == 'down') ? 'top' : 'left',
+ motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg',
+ distance,
+ animation = {};
// Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
- var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
- var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
- var distance = o.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
- if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el ).css({
+ overflow: 'hidden'
+ });
+
+ distance = o.distance || el[ ref == 'top' ? "outerHeight" : "outerWidth" ]({
+ margin: true
+ });
+ if (mode == 'show') {
+ el.css( ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance );
+ }
// Animation
- var animation = {};
- animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
+ animation[ ref ] = ( mode == 'show' ?
+ (motion == 'pos' ? '+=' : '-=') :
+ (motion == 'pos' ? '-=' : '+='))
+ + distance;
// Animate
- el.animate(animation, { queue: false, duration: o.duration, easing: o.easing, complete: function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.complete) o.complete.apply(this, arguments); // Callback
- el.dequeue();
- }});
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode == 'hide' ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ $.isFunction(o.complete) && o.complete.apply( this, arguments );
+ el.dequeue();
+ }
+ });
});