@@ -128,20 +128,22 @@ export default Vue.extend({
128128 // Items to render before and after the visible area
129129 bufferItems() {
130130 if (this .gridMode ) {
131+ // 1 row before and after in grid mode
131132 return this .columnCount
132133 }
134+ // 3 rows before and after
133135 return 3
134136 },
135137
136138 itemHeight() {
137139 // Align with css in FilesListVirtual
138- // 166px + 32px (name) + 16px (mtime) + 16px (padding)
139- return this .gridMode ? (166 + 32 + 16 + 16 ) : 55
140+ // 166px + 32px (name) + 16px (mtime) + 16px (padding top and bottom )
141+ return this .gridMode ? (166 + 32 + 16 + 16 + 16 ) : 55
140142 },
141143 // Grid mode only
142144 itemWidth() {
143- // 166px + 16px padding
144- return 166 + 16
145+ // 166px + 16px x 2 ( padding left and right)
146+ return 166 + 16 + 16
145147 },
146148
147149 rowCount() {
@@ -156,9 +158,13 @@ export default Vue.extend({
156158
157159 /**
158160 * Index of the first item to be rendered
161+ * The index can be any file, not just the first one
162+ * But the start index is the first item to be rendered,
163+ * which needs to align with the column count
159164 */
160165 startIndex() {
161- return Math .max (0 , this .index - this .bufferItems )
166+ const firstColumnIndex = this .index - (this .index % this .columnCount )
167+ return Math .max (0 , firstColumnIndex - this .bufferItems )
162168 },
163169
164170 /**
@@ -281,7 +287,7 @@ export default Vue.extend({
281287 scrollTo(index : number ) {
282288 const targetRow = Math .ceil (this .dataSources .length / this .columnCount )
283289 if (targetRow < this .rowCount ) {
284- logger .debug (' VirtualList: Skip scrolling. nothing to scroll' , { index , targetRow , rowCount: this .rowCount })
290+ logger .debug (' VirtualList: Skip scrolling, nothing to scroll' , { index , targetRow , rowCount: this .rowCount })
285291 return
286292 }
287293 this .index = index
0 commit comments