Skip to content

Commit

Permalink
Optimize the update effect of updateRows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaming743 committed Aug 19, 2020
1 parent 1c7e03b commit e67b4d5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/scrollBoard/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ export default {
animationHandler: '',
updater: 0
updater: 0,
needCalc: false
}
},
watch: {
Expand Down Expand Up @@ -335,6 +337,14 @@ export default {
this.aligns = deepMerge(aligns, align)
},
async animation (start = false) {
const { needCalc, calcHeights, calcRowsData } = this
if (needCalc) {
calcRowsData()
calcHeights()
this.needCalc = false
}
let { avgHeight, animationIndex, mergedConfig, rowsData, animation, updater } = this
const { waitTime, carousel, rowNum } = mergedConfig
Expand Down Expand Up @@ -389,15 +399,15 @@ export default {
})
},
updateRows(rows, animationIndex) {
const { mergedConfig, calcRowsData, calcHeights, animationHandler, animation } = this
const { mergedConfig, animationHandler, animation } = this
this.mergedConfig = {
...mergedConfig,
data: [...rows]
}
calcRowsData()
calcHeights()
this.needCalc = true
if (typeof animationIndex === 'number') this.animationIndex = animationIndex
if (!animationHandler) animation(true)
}
Expand Down

0 comments on commit e67b4d5

Please sign in to comment.