optmization for update data
This commit is contained in:
		@@ -33,19 +33,22 @@ export default {
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  watch: {
 | 
					  watch: {
 | 
				
			||||||
    data () {
 | 
					    data () {
 | 
				
			||||||
      const { init } = this
 | 
					      const { init, autoScrollHandler } = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      this.fade = false
 | 
				
			||||||
 | 
					      this.currentTopIndex = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      autoScrollHandler && clearTimeout(autoScrollHandler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      init()
 | 
					      init()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
    init () {
 | 
					    init () {
 | 
				
			||||||
      const { data, autoScrollHandler, getDealAfterData, getCurrentScrollData } = this
 | 
					      const { data, getDealAfterData, getCurrentScrollData } = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (!data) return
 | 
					      if (!data) return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      autoScrollHandler && clearTimeout(autoScrollHandler)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      getDealAfterData()
 | 
					      getDealAfterData()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      getCurrentScrollData()
 | 
					      getCurrentScrollData()
 | 
				
			||||||
@@ -68,14 +71,14 @@ export default {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      this.scrollData = tempArray
 | 
					      this.scrollData = tempArray
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setTimeout(doFade, 1500)
 | 
					      this.autoScrollHandler = setTimeout(doFade, 1500)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    doFade () {
 | 
					    doFade () {
 | 
				
			||||||
      const { reGetCurrentScrollData } = this
 | 
					      const { reGetCurrentScrollData } = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      this.fade = true
 | 
					      this.fade = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      setTimeout(reGetCurrentScrollData, 1500)
 | 
					      this.autoScrollHandler = setTimeout(reGetCurrentScrollData, 1500)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    reGetCurrentScrollData () {
 | 
					    reGetCurrentScrollData () {
 | 
				
			||||||
      const { getCurrentScrollData, dealAfterData, currentTopIndex } = this
 | 
					      const { getCurrentScrollData, dealAfterData, currentTopIndex } = this
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user