Skip to content

Commit ea35a7c

Browse files
committed
- fix not rendering items when changed
1 parent c348c8a commit ea35a7c

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-windowing",
3-
"version": "0.14.3",
3+
"version": "0.14.4",
44
"description": "Set of components used for virtualizing DOM",
55
"author": {
66
"name": "Maciej Kaczorowski",

src/components/AutoHeightMeasurer.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ export default {
1313
},
1414
},
1515
updated() {
16-
if (this.$el) {
17-
this.onHeightChange(this.$el.offsetHeight);
18-
}
16+
this.onHeightChange(this.$el.offsetHeight);
1917
},
2018
methods: {
2119
onHeightChange(height) {
22-
if (height !== this.height && height !== 0) {
20+
if (this.$el && height !== this.height && height !== 0) {
2321
this.$emit('height', {
2422
index: this.index,
2523
height,

src/components/VirtualScroll.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class="virtual-scroll__spacer">
1616
<AutoHeightMeasurer
1717
v-for="(item, index) in visibleItems"
18-
:key="`${index + startNode} | ${item.id || item}`"
18+
:key="`${item.id || item}`"
1919
:index="index + startNode"
2020
:height="cachedHeight[index + startNode] || estimatedHeight"
2121
@height="onMeasuredHeight">
@@ -75,16 +75,11 @@ export default {
7575
watch: {
7676
items(newValue, oldValue) {
7777
if (newValue.length !== oldValue.length) {
78-
const startNode = this.getFirstVisibleNode();
79-
const endNode = this.getLastVisibleNode(startNode);
80-
81-
this.firstVisibleNode = startNode;
82-
this.lastVisibleNode = endNode;
83-
8478
this.totalHeight = this.items.length * this.estimatedHeight;
8579
this.childPositions = {
8680
0: 0,
8781
};
82+
8883
this.cachedHeight = {};
8984
}
9085
},
@@ -155,6 +150,14 @@ export default {
155150
},
156151
onResize(entry) {
157152
this.height = entry.contentRect.height;
153+
154+
if (this.height > 0 && this.rowCount > 0) {
155+
const startNode = this.getFirstVisibleNode();
156+
const endNode = this.getLastVisibleNode(startNode);
157+
158+
this.firstVisibleNode = startNode;
159+
this.lastVisibleNode = endNode;
160+
}
158161
},
159162
onMeasuredHeight({
160163
index,

0 commit comments

Comments
 (0)