optmization for update data

This commit is contained in:
jiaming 2018-12-08 19:16:30 +08:00
parent adb33f9326
commit 097b2670d7
1 changed files with 9 additions and 6 deletions

View File

@ -33,19 +33,22 @@ export default {
},
watch: {
data () {
const { init } = this
const { init, autoScrollHandler } = this
this.fade = false
this.currentTopIndex = 0
autoScrollHandler && clearTimeout(autoScrollHandler)
init()
}
},
methods: {
init () {
const { data, autoScrollHandler, getDealAfterData, getCurrentScrollData } = this
const { data, getDealAfterData, getCurrentScrollData } = this
if (!data) return
autoScrollHandler && clearTimeout(autoScrollHandler)
getDealAfterData()
getCurrentScrollData()
@ -68,14 +71,14 @@ export default {
this.scrollData = tempArray
setTimeout(doFade, 1500)
this.autoScrollHandler = setTimeout(doFade, 1500)
},
doFade () {
const { reGetCurrentScrollData } = this
this.fade = true
setTimeout(reGetCurrentScrollData, 1500)
this.autoScrollHandler = setTimeout(reGetCurrentScrollData, 1500)
},
reGetCurrentScrollData () {
const { getCurrentScrollData, dealAfterData, currentTopIndex } = this