Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accordion: Attempt at improving animation. #587

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Accordion: Cleaned up height equalization.
  • Loading branch information
scottgonzalez committed Feb 12, 2012
commit 779c45bf65918bd1f5f12fe7089eb2308e1b31c4
50 changes: 26 additions & 24 deletions ui/jquery.ui.accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,18 +432,20 @@ $.widget( "ui.accordion", {
$.extend( $.ui.accordion, {
animations: {
slide: function( options ) {
var total;

if ( !options.toHide.size() ) {
return options.toShow.animate( showProps, options );
}
if ( !options.toShow.size() ) {
return options.toHide.animate( hideProps, options );
}

var total = options.toShow.show().outerHeight();
total = options.toShow.show().outerHeight();
options.toHide.animate( hideProps, options );
options.toShow
.hide()
.data( "togglePair", {
.data( "accordionHeight", {
total: total,
toHide: options.toHide
})
Expand All @@ -452,21 +454,35 @@ $.extend( $.ui.accordion, {
easing: options.easing,
complete: function() {
setTimeout(function() {
options.toShow.removeData( "togglePair" );
options.toShow.removeData( "accordionHeight" );
options.complete();
}, 1 );
}
});
},
bounceslide: function( options ) {
this.slide( $.extend( options, {
easing: options.down ? "easeOutBounce" : "swing",
duration: options.down ? 1000 : 200
}));
}
},
bounceslide: function( options ) {
this.slide( $.extend( options, {
easing: options.down ? "easeOutBounce" : "swing",
duration: options.down ? 1000 : 200
}));
}
}
});

$.fx.step.accordionHeight = function( fx ) {
var elem = $( fx.elem ),
data = elem.data( "accordionHeight" );
elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() );
};
var hideProps = {},
showProps = {},
showPropsAdjust = {};
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
showProps.height = showProps.paddingTop = showProps.paddingBottom =
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.extend( showPropsAdjust, showProps, { accordionHeight: "show" } );



// DEPRECATED
Expand Down Expand Up @@ -611,18 +627,4 @@ if ( $.uiBackCompat !== false ) {
}( jQuery, jQuery.ui.accordion.prototype ) );
}

$.fx.step._height = function( fx ) {
var elem = $( fx.elem ),
data = elem.data( "togglePair" );
elem.height( data.total - elem.outerHeight() - data.toHide.outerHeight() + elem.height() );
};
var hideProps = {},
showProps = {},
showPropsAdjust = {};
hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
showProps.height = showProps.paddingTop = showProps.paddingBottom =
showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.extend( showPropsAdjust, showProps, { _height: "show" } );

})( jQuery );