feat:fix when continious reset list,then getBatchedItems will continious call twice

This commit is contained in:
pengfei.zhou 2020-03-24 16:13:59 +08:00 committed by osborn
parent 4ea6da2d0a
commit e46f09427b

View File

@ -89,12 +89,9 @@ export class List extends Superview implements IList {
this.itemCount = 0 this.itemCount = 0
} }
private getItem(itemIdx: number) { private getItem(itemIdx: number) {
let view = this.cachedViews.get(`${itemIdx}`) let view = this.renderItem(itemIdx)
if (view === undefined) { view.superview = this
view = this.renderItem(itemIdx) this.cachedViews.set(`${itemIdx}`, view)
view.superview = this
this.cachedViews.set(`${itemIdx}`, view)
}
return view return view
} }
@ -108,7 +105,7 @@ export class List extends Superview implements IList {
} }
private renderBunchedItems(start: number, length: number) { private renderBunchedItems(start: number, length: number) {
this.ignoreDirtyCallOnce = true; this.ignoreDirtyCallOnce = true
return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => { return new Array(Math.min(length, this.itemCount - start)).fill(0).map((_, idx) => {
const listItem = this.getItem(start + idx) const listItem = this.getItem(start + idx)
return listItem.toModel() return listItem.toModel()