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: Fixed animation for heightStyle: content; Force height of …
…accordion for non-content heightStyle to improve animation in Firefox.
  • Loading branch information
scottgonzalez committed Feb 12, 2012
commit 0f43dc43177bb5065cf6ef077fa88fc6a65fa1dc
22 changes: 10 additions & 12 deletions ui/jquery.ui.accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ $.widget( "ui.accordion", {
this.active.next().addClass( "ui-accordion-content-active" );

this._createIcons();
this.originalHeight = this.element[0].style.height;
this.refresh();

// ARIA
Expand Down Expand Up @@ -157,6 +158,7 @@ $.widget( "ui.accordion", {
.removeAttr( "role" )
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
if ( this.options.heightStyle !== "content" ) {
this.element.css( "height", this.originalHeight );
contents.css( "height", "" );
}
},
Expand Down Expand Up @@ -230,12 +232,12 @@ $.widget( "ui.accordion", {
},

refresh: function() {
var options = this.options,
var heightStyle = this.options.heightStyle,
parent = this.element.parent(),
maxHeight,
overflow;

if ( options.heightStyle === "fill" ) {
if ( heightStyle === "fill" ) {
// IE 6 treats height like minHeight, so we need to turn off overflow
// in order to get a reliable height
// we use the minHeight support test because we assume that only
Expand Down Expand Up @@ -268,7 +270,7 @@ $.widget( "ui.accordion", {
$( this ).innerHeight() + $( this ).height() ) );
})
.css( "overflow", "auto" );
} else if ( options.heightStyle === "auto" ) {
} else if ( heightStyle === "auto" ) {
maxHeight = 0;
this.headers.next()
.each(function() {
Expand All @@ -277,7 +279,9 @@ $.widget( "ui.accordion", {
.height( maxHeight );
}

return this;
if ( heightStyle !== "content" ) {
this.element.height( this.element.height() );
}
},

_activate: function( index ) {
Expand Down Expand Up @@ -434,20 +438,14 @@ $.widget( "ui.accordion", {
total: total,
toHide: toHide
})
.animate( showPropsAdjust, duration, easing, complete );
.animate( this.options.heightStyle === "content" ? showProps : showPropsAdjust,
duration, easing, complete );
},

_completed: function( data ) {
var toShow = data.newContent,
toHide = data.oldContent;

if ( this.options.heightStyle === "content" ) {
toShow.add( toHide ).css({
height: "",
overflow: ""
});
}

// other classes are removed before the animation; this one needs to stay until completed
toHide.removeClass( "ui-accordion-content-active" );
// Work around for rendering bug in IE (#5421)
Expand Down