Skip to content

Commit e67b4d5

Browse files
committed
Optimize the update effect of updateRows.
1 parent 1c7e03b commit e67b4d5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/components/scrollBoard/src/main.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ export default {
178178
179179
animationHandler: '',
180180
181-
updater: 0
181+
updater: 0,
182+
183+
needCalc: false
182184
}
183185
},
184186
watch: {
@@ -335,6 +337,14 @@ export default {
335337
this.aligns = deepMerge(aligns, align)
336338
},
337339
async animation (start = false) {
340+
const { needCalc, calcHeights, calcRowsData } = this
341+
342+
if (needCalc) {
343+
calcRowsData()
344+
calcHeights()
345+
this.needCalc = false
346+
}
347+
338348
let { avgHeight, animationIndex, mergedConfig, rowsData, animation, updater } = this
339349
340350
const { waitTime, carousel, rowNum } = mergedConfig
@@ -389,15 +399,15 @@ export default {
389399
})
390400
},
391401
updateRows(rows, animationIndex) {
392-
const { mergedConfig, calcRowsData, calcHeights, animationHandler, animation } = this
402+
const { mergedConfig, animationHandler, animation } = this
393403
394404
this.mergedConfig = {
395405
...mergedConfig,
396406
data: [...rows]
397407
}
398408
399-
calcRowsData()
400-
calcHeights()
409+
this.needCalc = true
410+
401411
if (typeof animationIndex === 'number') this.animationIndex = animationIndex
402412
if (!animationHandler) animation(true)
403413
}

0 commit comments

Comments
 (0)