only cache width on item construction (not on list resize)
This commit is contained in:
parent
4eef6ece64
commit
c31ff816c1
3 changed files with 7 additions and 5 deletions
|
@ -23,7 +23,7 @@ Ox.load('Geo', function() {
|
||||||
area = Math.sqrt(city.population * 100),
|
area = Math.sqrt(city.population * 100),
|
||||||
latSize = area / Ox.EARTH_CIRCUMFERENCE * 360,
|
latSize = area / Ox.EARTH_CIRCUMFERENCE * 360,
|
||||||
lngSize = area * Ox.getDegreesPerMeter(city.latitude);
|
lngSize = area * Ox.getDegreesPerMeter(city.latitude);
|
||||||
return city.population > 400000/*400000*/ ? {
|
return city.population > 100000/*400000*/ ? {
|
||||||
area: city.population * 100,
|
area: city.population * 100,
|
||||||
countryCode: countryCode,
|
countryCode: countryCode,
|
||||||
editable: true,
|
editable: true,
|
||||||
|
|
|
@ -417,7 +417,7 @@ Ox.List = function(options, self) {
|
||||||
|
|
||||||
function emptyFirstPage() {
|
function emptyFirstPage() {
|
||||||
//Ox.print('emptyFirstPage', self.$pages);
|
//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() {
|
function fillFirstPage() {
|
||||||
|
|
|
@ -367,7 +367,7 @@ Ox.TextList = function(options, self) {
|
||||||
var $item = $('<div>')
|
var $item = $('<div>')
|
||||||
.addClass('OxTarget')
|
.addClass('OxTarget')
|
||||||
.css({
|
.css({
|
||||||
width: getItemWidth() + 'px'
|
width: getItemWidth(true) + 'px'
|
||||||
});
|
});
|
||||||
self.visibleColumns.forEach(function(v, i) {
|
self.visibleColumns.forEach(function(v, i) {
|
||||||
//Ox.print(data[v.id], '(--value--)')
|
//Ox.print(data[v.id], '(--value--)')
|
||||||
|
@ -525,13 +525,15 @@ Ox.TextList = function(options, self) {
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItemWidth() {
|
function getItemWidth(cached) {
|
||||||
// fixme: this gets called for every constructItem and is slooow
|
// fixme: this gets called for every constructItem and is slooow
|
||||||
// the proper way to fix this would be to find out how and when
|
// the proper way to fix this would be to find out how and when
|
||||||
// that.$element.width() might change... which would probably
|
// that.$element.width() might change... which would probably
|
||||||
// mean binding to every SplitPanel and window resize...
|
// mean binding to every SplitPanel and window resize...
|
||||||
// for now, use a cached value
|
// 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.cachedWidth = that.$element.width();
|
||||||
self.cachedWidthTime = +new Date();
|
self.cachedWidthTime = +new Date();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue