Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(files): virtual scroller item size computation #49561

Open
wants to merge 1 commit into
base: stable30
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions apps/files/src/components/VirtualList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,22 @@ export default Vue.extend({
// Items to render before and after the visible area
bufferItems() {
if (this.gridMode) {
// 1 row before and after in grid mode
return this.columnCount
}
// 3 rows before and after
return 3
},

itemHeight() {
// Align with css in FilesListVirtual
// 166px + 32px (name) + 16px (mtime) + 16px (padding)
return this.gridMode ? (166 + 32 + 16 + 16) : 55
// 166px + 32px (name) + 16px (mtime) + 16px (padding top and bottom)
return this.gridMode ? (166 + 32 + 16 + 16 + 16) : 55
},
// Grid mode only
itemWidth() {
// 166px + 16px padding
return 166 + 16
// 166px + 16px x 2 (padding left and right)
return 166 + 16 + 16
},

rowCount() {
Expand All @@ -156,9 +158,13 @@ export default Vue.extend({

/**
* Index of the first item to be rendered
* The index can be any file, not just the first one
* But the start index is the first item to be rendered,
* which needs to align with the column count
*/
startIndex() {
return Math.max(0, this.index - this.bufferItems)
const firstColumnIndex = this.index - (this.index % this.columnCount)
return Math.max(0, firstColumnIndex - this.bufferItems)
},

/**
Expand Down Expand Up @@ -281,7 +287,7 @@ export default Vue.extend({
scrollTo(index: number) {
const targetRow = Math.ceil(this.dataSources.length / this.columnCount)
if (targetRow < this.rowCount) {
logger.debug('VirtualList: Skip scrolling. nothing to scroll', { index, targetRow, rowCount: this.rowCount })
logger.debug('VirtualList: Skip scrolling, nothing to scroll', { index, targetRow, rowCount: this.rowCount })
return
}
this.index = index
Expand Down
Loading