Skip to content

Commit 00e29f3

Browse files
committed
handle change in items.length from zero to some
1 parent 1b23f2d commit 00e29f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/VirtualList.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
this.on('state', ({ changed, previous, current }) => {
8484
if (changed.items || changed.height || changed.itemHeight) {
85-
if (changed.itemHeight || current.items.length !== this.heightMap.length) {
85+
if (current.itemHeight && (changed.itemHeight || current.items.length !== this.heightMap.length)) {
8686
this.heightMap = current.items.map(() => current.itemHeight);
8787
}
8888

@@ -115,6 +115,8 @@
115115
}
116116

117117
for (; i < items.length; i += 1) {
118+
if (!(i in this.heightMap)) break;
119+
118120
offset += this.heightMap[i];
119121
if (offset > scrollTop) break;
120122

0 commit comments

Comments
 (0)