Skip to content
Permalink
Browse files

Accordion: Partial fix for #4011: Smooth(er) animations with autoHeig…

…ht: false.

Removed some browser snifing.
Added support for non-px units.
  • Loading branch information
scottgonzalez committed Jan 31, 2009
1 parent 39dac81 commit 6695e5ac7f5be9be2b25f62314ba80812a5fbf65
Showing with 17 additions and 9 deletions.
  1. +17 −9 ui/ui.accordion.js
@@ -395,29 +395,37 @@ $.extend($.ui.accordion, {
return;
}
var overflow = options.toShow.css('overflow'),
percentDone,
showProps = {},
hideProps = {},
fxAttrs = [ "height", "paddingTop", "paddingBottom" ];
$.each(fxAttrs, function(i, prop) {
hideProps[prop] = 'hide';
showProps[prop] = parseFloat(options.toShow.css(prop));

if (options.toShow[0]) {
var parts = ('' + $.css(options.toShow[0], prop)).match(/^([\d+-.]+)(.*)$/);
showProps[prop] = {
value: parts[1],
unit: parts[2] || 'px'
};
}
});
showProps.height = options.toShow.height();
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{
step: function(now, settings) {
// if the alwaysOpen option is set to false, we may not have
// a content pane to show
if (!options.toShow[0]) { return; }

var percentDone = settings.start != settings.end
? (settings.now - settings.start) / (settings.end - settings.start)
: 0,
current = percentDone * showProps[settings.prop];
if ($.browser.msie || $.browser.opera) {
current = Math.ceil(current);
// only calculate the percent when animating height
// IE gets very inconsistent results when animating elements
// with small values, which is common for padding
if (settings.prop == 'height') {
percentDone = (settings.now - settings.start) / (settings.end - settings.start);
}
options.toShow[0].style[settings.prop] = current + 'px';

options.toShow[0].style[settings.prop] =
(percentDone * showProps[settings.prop].value) + showProps[settings.prop].unit;
},
duration: options.duration,
easing: options.easing,

0 comments on commit 6695e5a

Please sign in to comment.
You can’t perform that action at this time.