r1926 - trunk/ui
r1926 - trunk/ui
Author: scott.gonzalez
Date: Fri Jan 30 18:55:56 2009
New Revision: 1926
Modified:
trunk/ui/ui.accordion.js
Log:
Accordion: Partial fix for #4011: Smooth(er) animations with autoHeight:
false.
Removed some browser snifing.
Added support for non-px units.
Modified: trunk/ui/ui.accordion.js
==============================================================================
--- trunk/ui/ui.accordion.js (original)
+++ trunk/ui/ui.accordion.js Fri Jan 30 18:55:56 2009
@@ -395,14 +395,21 @@
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) {
@@ -410,14 +417,15 @@
// 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,