reducing textlist item construction time by about 80%

This commit is contained in:
rolux 2011-05-24 19:50:53 +02:00
commit 4eef6ece64
3 changed files with 17 additions and 6 deletions

View file

@ -526,12 +526,20 @@ Ox.TextList = function(options, self) {
}
function getItemWidth() {
// fixme: this gets called for every constructItem and is slooow
// the proper way to fix this would be to find out how and when
// that.$element.width() might change... which would probably
// mean binding to every SplitPanel and window resize...
// for now, use a cached value
if (!self.cachedWidth || self.cachedWidthTime < +new Date() - 5000) {
self.cachedWidth = that.$element.width();
self.cachedWidthTime = +new Date();
}
return Math.max(
Ox.sum(self.columnWidths),
that.$element.width() -
self.cachedWidth -
(self.options.scrollbarVisible ? Ox.UI.SCROLLBAR_SIZE : 0)
);
//return Ox.sum(self.columnWidths)
}
function moveColumn(id, pos) {
@ -776,6 +784,7 @@ Ox.TextList = function(options, self) {
}
that.size = function() {
Ox.print('SIZE FUNCTION CALLED')
setWidth();
that.$body.size();
}