Skip to content

Commit bfa35f2

Browse files
author
Guillaume Chau
committed
Skip initial update for SSR when re-hydrating
1 parent d6dcde3 commit bfa35f2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/components/VirtualScroller.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ export default {
230230
const scrollTop = ~~(scroll.top / poolSize) * poolSize - buffer
231231
const scrollBottom = Math.ceil(scroll.bottom / poolSize) * poolSize + buffer
232232
233-
if (!force && scrollTop === this._oldScrollTop && scrollBottom === this._oldScrollBottom) {
233+
if (!force && ((scrollTop === this._oldScrollTop && scrollBottom === this._oldScrollBottom) || this._skip)) {
234+
this._skip = false
234235
return
235236
} else {
236237
this._oldScrollTop = scrollTop
@@ -375,14 +376,18 @@ export default {
375376
this._startIndex = 0
376377
this._oldScrollTop = null
377378
this._oldScrollBottom = null
379+
this._offsetTop = 0
380+
this._height = 0
378381
const prerender = parseInt(this.prerender)
379382
if (prerender > 0) {
380383
this.visibleItems = this.items.slice(0, prerender)
381384
this._length = this.visibleItems.length
382385
this._endIndex = this._length - 1
386+
this._skip = true
383387
} else {
384388
this._endIndex = 0
385389
this._length = 0
390+
this._skip = false
386391
}
387392
},
388393

0 commit comments

Comments
 (0)