From c31ff816c1454f83effd576da9151d489dc6812f Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 24 May 2011 20:32:59 +0200 Subject: [PATCH] only cache width on item construction (not on list resize) --- demos/listmap2/js/listmap.js | 2 +- source/Ox.UI/js/List/Ox.List.js | 2 +- source/Ox.UI/js/List/Ox.TextList.js | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/demos/listmap2/js/listmap.js b/demos/listmap2/js/listmap.js index c6771c4b..2a68371d 100644 --- a/demos/listmap2/js/listmap.js +++ b/demos/listmap2/js/listmap.js @@ -23,7 +23,7 @@ Ox.load('Geo', function() { area = Math.sqrt(city.population * 100), latSize = area / Ox.EARTH_CIRCUMFERENCE * 360, lngSize = area * Ox.getDegreesPerMeter(city.latitude); - return city.population > 400000/*400000*/ ? { + return city.population > 100000/*400000*/ ? { area: city.population * 100, countryCode: countryCode, editable: true, diff --git a/source/Ox.UI/js/List/Ox.List.js b/source/Ox.UI/js/List/Ox.List.js index a5926002..7e35c768 100644 --- a/source/Ox.UI/js/List/Ox.List.js +++ b/source/Ox.UI/js/List/Ox.List.js @@ -417,7 +417,7 @@ Ox.List = function(options, self) { function emptyFirstPage() { //Ox.print('emptyFirstPage', self.$pages); - self.$pages[0] && self.$pages[0].find('.OxEmpty').removeElement(); + self.$pages[0] && self.$pages[0].find('.OxEmpty').remove(); } function fillFirstPage() { diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index 6f55dd46..f7ecfb2c 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -367,7 +367,7 @@ Ox.TextList = function(options, self) { var $item = $('
') .addClass('OxTarget') .css({ - width: getItemWidth() + 'px' + width: getItemWidth(true) + 'px' }); self.visibleColumns.forEach(function(v, i) { //Ox.print(data[v.id], '(--value--)') @@ -525,13 +525,15 @@ Ox.TextList = function(options, self) { return $item; } - function getItemWidth() { + function getItemWidth(cached) { // 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) { + if (!cached) { + self.cachedWidth = that.$element.width(); + } else if (!self.cachedWidth || self.cachedWidthTime < +new Date() - 5000) { self.cachedWidth = that.$element.width(); self.cachedWidthTime = +new Date(); }