@@ -155,7 +155,7 @@ export default defineComponent({
155155 /**
156156 * The number of rows currently (fully!) visible
157157 */
158- visualRows (): number {
158+ visibleRows (): number {
159159 return Math .floor ((this .tableHeight - this .headerHeight ) / this .itemHeight )
160160 },
161161
@@ -164,7 +164,7 @@ export default defineComponent({
164164 * This includes only visible + buffer rows.
165165 */
166166 rowCount(): number {
167- return this .visualRows + (this .bufferItems / this .columnCount ) * 2 + 1
167+ return this .visibleRows + (this .bufferItems / this .columnCount ) * 2 + 1
168168 },
169169
170170 /**
@@ -238,13 +238,15 @@ export default defineComponent({
238238 },
239239
240240 tbodyStyle() {
241+ // The number of (virtual) rows above the currently rendered ones.
241242 // start index is aligned so this should always be an integer
242- const rowsBefore = Math .round (this .startIndex / this .columnCount )
243- const rowsAfter = Math .min (0 , this .totalRowCount - rowsBefore - this .rowCount )
243+ const rowsAbove = Math .round (this .startIndex / this .columnCount )
244+ // The number of (virtual) rows below the currently rendered ones.
245+ const rowsBelow = Math .min (0 , this .totalRowCount - rowsAbove - this .rowCount )
244246
245247 return {
246- paddingTop: ` ${rowsBefore * this .itemHeight }px ` ,
247- paddingBottom: ` ${rowsAfter * this .itemHeight }px ` ,
248+ paddingTop: ` ${rowsAbove * this .itemHeight }px ` ,
249+ paddingBottom: ` ${rowsBelow * this .itemHeight }px ` ,
248250 minHeight: ` ${this .totalRowCount * this .itemHeight }px ` ,
249251 }
250252 },
@@ -286,8 +288,9 @@ export default defineComponent({
286288 // Make sure height values are initialized
287289 this .updateHeightVariables ()
288290
289- // If we need to scroll to an index we do so in the next tick
290- // this is needed to apply updates from the initialization of the height variables
291+ // If we need to scroll to an index we do so in the next tick.
292+ // This is needed to apply updates from the initialization of the height variables
293+ // which will update the tbody styles until next tick.
291294 if (this .scrollToIndex ) {
292295 this .$nextTick (() => this .scrollTo (this .scrollToIndex ))
293296 }
@@ -311,17 +314,17 @@ export default defineComponent({
311314 }
312315
313316 // Check if the content is smaller than the viewport, meaning no scrollbar
314- if (this .totalRowCount < this .visualRows ) {
317+ if (this .totalRowCount < this .visibleRows ) {
315318 logger .debug (' VirtualList: Skip scrolling, nothing to scroll' , {
316319 index ,
317320 totalRows: this .totalRowCount ,
318- visualRows : this .visualRows ,
321+ visibleRows : this .visibleRows ,
319322 })
320323 return
321324 }
322325
323326 // We can not scroll further as the last page of rows (+ footer)
324- const clampedIndex = (this .totalRowCount - this .visualRows + 1 ) * this .columnCount
327+ const clampedIndex = (this .totalRowCount - this .visibleRows + 1 ) * this .columnCount
325328 let scrollTop = this .indexToScrollPos (Math .min (index , clampedIndex ))
326329
327330 // If this is not the first row we can add a half row from above.
@@ -330,7 +333,7 @@ export default defineComponent({
330333 if (index > 0 && index <= clampedIndex ) {
331334 scrollTop -= (this .itemHeight / 2 )
332335 }
333- logger .debug (' VirtualList: scrolling to index ' + index , { clampedIndex , scrollTop , columnCount: this .columnCount , total: this .totalRowCount , visualRows : this .visualRows , beforeHeight: this .beforeHeight })
336+ logger .debug (' VirtualList: scrolling to index ' + index , { clampedIndex , scrollTop , columnCount: this .columnCount , total: this .totalRowCount , visibleRows : this .visibleRows , beforeHeight: this .beforeHeight })
334337 this .$el .scrollTop = scrollTop
335338 },
336339
0 commit comments