Skip to content

Commit

Permalink
Bug Fixes: #25
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaming743 committed Nov 12, 2019
1 parent bbdf7ea commit 3ad05eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/components/scrollBoard/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ export default {
animationIndex: 0,
animationHandler: ''
animationHandler: '',
updater: 0
}
},
watch: {
Expand Down Expand Up @@ -304,15 +306,18 @@ export default {
this.aligns = deepMerge(aligns, align)
},
async animation (start = false) {
let { avgHeight, animationIndex, mergedConfig, rowsData, animation } = this
let { avgHeight, animationIndex, mergedConfig, rowsData, animation, updater } = this
const { waitTime, carousel, rowNum } = mergedConfig
const rowLength = rowsData.length
if (rowNum >= rowLength) return
if (start) await new Promise(resolve => setTimeout(resolve, waitTime))
if (start) {
await new Promise(resolve => setTimeout(resolve, waitTime))
if (updater !== this.updater) return
}
const animationNum = carousel === 'single' ? 1 : rowNum
Expand All @@ -323,6 +328,7 @@ export default {
this.heights = new Array(rowLength).fill(avgHeight)
await new Promise(resolve => setTimeout(resolve, 300))
if (updater !== this.updater) return
this.heights.splice(0, animationNum, ...new Array(animationNum).fill(0))
Expand All @@ -335,7 +341,9 @@ export default {
this.animationHandler = setTimeout(animation, waitTime - 300)
},
stopAnimation () {
const { animationHandler } = this
const { animationHandler, updater } = this
this.updater = (updater + 1) % 999999
if (!animationHandler) return
Expand Down
16 changes: 12 additions & 4 deletions src/components/scrollRankingBoard/src/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export default {
animationIndex: 0,
animationHandler: ''
animationHandler: '',
updater: 0
}
},
watch: {
Expand Down Expand Up @@ -172,15 +174,18 @@ export default {
if (!onresize) this.heights = new Array(data.length).fill(avgHeight)
},
async animation (start = false) {
let { avgHeight, animationIndex, mergedConfig, rowsData, animation } = this
let { avgHeight, animationIndex, mergedConfig, rowsData, animation, updater } = this
const { waitTime, carousel, rowNum } = mergedConfig
const rowLength = rowsData.length
if (rowNum >= rowLength) return
if (start) await new Promise(resolve => setTimeout(resolve, waitTime))
if (start) {
await new Promise(resolve => setTimeout(resolve, waitTime))
if (updater !== this.updater) return
}
const animationNum = carousel === 'single' ? 1 : rowNum
Expand All @@ -191,6 +196,7 @@ export default {
this.heights = new Array(rowLength).fill(avgHeight)
await new Promise(resolve => setTimeout(resolve, 300))
if (updater !== this.updater) return
this.heights.splice(0, animationNum, ...new Array(animationNum).fill(0))
Expand All @@ -203,7 +209,9 @@ export default {
this.animationHandler = setTimeout(animation, waitTime - 300)
},
stopAnimation () {
const { animationHandler } = this
const { animationHandler, updater } = this
this.updater = (updater + 1) % 999999
if (!animationHandler) return
Expand Down

0 comments on commit 3ad05eb

Please sign in to comment.