vue中touchEnd事件和touchStart、touchMove獲取座標不一樣
阿新 • • 發佈:2021-01-12
touchEnd ~~~~~~~~~~~~~~~~ e.changedTouches[0].pageY
touchStart ~~~~~~~~~~~~~~~~ e.targetTouches[0].pageY
touchMove ~~~~~~~~~~~~~~~~ e.changedTouches[0].pageY
1 activated() { 2 this.listenerFunction() 3 }, 4 destroyed() { 5 window.removeEventListener('scroll', this.listenerFunction) 6}, 7 methods{ 8 scrollBottom() { 9 const windowHeight = window.screen.height 10 const scrollTop = document.documentElement.scrollTop || document.body.scrollTop 11 const contentHeight = this.$refs.scoreMallContainer.clientHeight 12 const toBottom = contentHeight - windowHeight - scrollTop13 this.toBottom = toBottom 14 }, 15 touchstart(e) { 16 this.startPageY = e.targetTouches[0].pageY 17 }, 18 touchend(e) { 19 this.endPageY = e.changedTouches[0].pageY 20 if (!this.toBottom && this.endPageY - this.startPageY < 0) { 21 if (!this.$refs.taskView.popup) {22 this.$refs.taskView.popupSwich() 23 } 24 } 25 }, 26 }
1 popupSwich() { 2 this.popup = !this.popup 3 const taskBoxStyle = this.$refs.taskBox.style 4 this.popup ? taskBoxStyle.overflow = 'scroll' : taskBoxStyle.overflow = 'hidden' 5 },