Search and Top Navigation
Ticket #3788: accordion-jump-improvement.patch
File accordion-jump-improvement.patch, 3.1 KB (added by scottgonzalez, January 29, 2009 09:58PM UTC)
patch to be applied with Jörn's latest patch - improves the jump and removes the container height setting
Index: /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js
===================================================================
--- /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js (revision 1876)
+++ /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js (working copy)
@@ -33,8 +33,7 @@
this.element.addClass("ui-accordion ui-widget ui-helper-reset");
- this.groups = this.element.children().addClass("ui-accordion-group");
- this.headers = this.groups.find("> :first-child").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
+ this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
.bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); })
.bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); });
@@ -41,10 +40,7 @@
// wrap content elements in div against animation issues
this.headers
.next()
- .wrap("")
- .addClass("ui-accordion-content")
- .parent()
- .addClass("ui-accordion-content-wrap ui-helper-reset ui-widget-content ui-corner-bottom");
+ .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");
this.active.parent().addClass('ui-accordion-selected');
@@ -330,7 +326,7 @@
});
};
}
-
+
animations[easing](animOptions);
} else {
@@ -364,9 +360,8 @@
overflow: ""
});
}
-
+
this._trigger('change', null, this.data);
-
}
});
@@ -405,15 +400,26 @@
var hideHeight = options.toHide.height(),
showHeight = options.toShow.height(),
difference = showHeight / hideHeight,
- overflow = options.toShow.css('overflow');
+ overflow = options.toShow.css('overflow'),
+ showProps = {},
+ hideProps = {},
+ fxAttrs = [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom", "borderTop", "borderBottom" ];
+ $.browser.msie && fxAttrs.pop() && fxAttrs.pop();
+ $.each(fxAttrs, function(i, prop) {
+ hideProps[prop] = 'hide';
+ showProps[prop] = parseFloat(options.toShow.css(prop));
+ });
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
- options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
- step: function(now) {
- var current = (hideHeight - now) * difference;
+ options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{
+ step: function(now, settings) {
+ 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);
}
- options.toShow.height( current );
+ options.toShow[0].style[settings.prop] = current + 'px';
},
duration: options.duration,
easing: options.easing,
Download in other formats:
Original Format
File accordion-jump-improvement.patch, 3.1 KB (added by scottgonzalez, January 29, 2009 09:58PM UTC)
patch to be applied with Jörn's latest patch - improves the jump and removes the container height setting
Index: /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js
===================================================================
--- /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js (revision 1876)
+++ /Users/sgonzale/Documents/workspace/jQuery UI/ui/ui.accordion.js (working copy)
@@ -33,8 +33,7 @@
this.element.addClass("ui-accordion ui-widget ui-helper-reset");
- this.groups = this.element.children().addClass("ui-accordion-group");
- this.headers = this.groups.find("> :first-child").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
+ this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all")
.bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); })
.bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); });
@@ -41,10 +40,7 @@
// wrap content elements in div against animation issues
this.headers
.next()
- .wrap("")
- .addClass("ui-accordion-content")
- .parent()
- .addClass("ui-accordion-content-wrap ui-helper-reset ui-widget-content ui-corner-bottom");
+ .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");
this.active.parent().addClass('ui-accordion-selected');
@@ -330,7 +326,7 @@
});
};
}
-
+
animations[easing](animOptions);
} else {
@@ -364,9 +360,8 @@
overflow: ""
});
}
-
+
this._trigger('change', null, this.data);
-
}
});
@@ -405,15 +400,26 @@
var hideHeight = options.toHide.height(),
showHeight = options.toShow.height(),
difference = showHeight / hideHeight,
- overflow = options.toShow.css('overflow');
+ overflow = options.toShow.css('overflow'),
+ showProps = {},
+ hideProps = {},
+ fxAttrs = [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom", "borderTop", "borderBottom" ];
+ $.browser.msie && fxAttrs.pop() && fxAttrs.pop();
+ $.each(fxAttrs, function(i, prop) {
+ hideProps[prop] = 'hide';
+ showProps[prop] = parseFloat(options.toShow.css(prop));
+ });
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
- options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
- step: function(now) {
- var current = (hideHeight - now) * difference;
+ options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate(hideProps,{
+ step: function(now, settings) {
+ 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);
}
- options.toShow.height( current );
+ options.toShow[0].style[settings.prop] = current + 'px';
},
duration: options.duration,
easing: options.easing,