Fix:修复移动端部分浏览器设置缩放时会进行页面缩放的问题
This commit is contained in:
parent
27477e39de
commit
53bcabe3d0
@ -16,10 +16,12 @@ class TouchEvent {
|
|||||||
this.onTouchmove = this.onTouchmove.bind(this)
|
this.onTouchmove = this.onTouchmove.bind(this)
|
||||||
this.onTouchcancel = this.onTouchcancel.bind(this)
|
this.onTouchcancel = this.onTouchcancel.bind(this)
|
||||||
this.onTouchend = this.onTouchend.bind(this)
|
this.onTouchend = this.onTouchend.bind(this)
|
||||||
window.addEventListener('touchstart', this.onTouchstart)
|
window.addEventListener('touchstart', this.onTouchstart, { passive: false })
|
||||||
window.addEventListener('touchmove', this.onTouchmove)
|
window.addEventListener('touchmove', this.onTouchmove, { passive: false })
|
||||||
window.addEventListener('touchcancel', this.onTouchcancel)
|
window.addEventListener('touchcancel', this.onTouchcancel, {
|
||||||
window.addEventListener('touchend', this.onTouchend)
|
passive: false
|
||||||
|
})
|
||||||
|
window.addEventListener('touchend', this.onTouchend, { passive: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解绑事件
|
// 解绑事件
|
||||||
@ -32,6 +34,7 @@ class TouchEvent {
|
|||||||
|
|
||||||
// 手指按下事件
|
// 手指按下事件
|
||||||
onTouchstart(e) {
|
onTouchstart(e) {
|
||||||
|
e.preventDefault()
|
||||||
this.touchesNum = e.touches.length
|
this.touchesNum = e.touches.length
|
||||||
this.touchStartScaleView = null
|
this.touchStartScaleView = null
|
||||||
if (this.touchesNum === 1) {
|
if (this.touchesNum === 1) {
|
||||||
@ -43,6 +46,7 @@ class TouchEvent {
|
|||||||
|
|
||||||
// 手指移动事件
|
// 手指移动事件
|
||||||
onTouchmove(e) {
|
onTouchmove(e) {
|
||||||
|
e.preventDefault()
|
||||||
let len = e.touches.length
|
let len = e.touches.length
|
||||||
if (len === 1) {
|
if (len === 1) {
|
||||||
let touch = e.touches[0]
|
let touch = e.touches[0]
|
||||||
@ -103,6 +107,7 @@ class TouchEvent {
|
|||||||
|
|
||||||
// 手指松开事件
|
// 手指松开事件
|
||||||
onTouchend(e) {
|
onTouchend(e) {
|
||||||
|
e.preventDefault()
|
||||||
this.dispatchMouseEvent('mouseup', e.target)
|
this.dispatchMouseEvent('mouseup', e.target)
|
||||||
if (this.touchesNum === 1) {
|
if (this.touchesNum === 1) {
|
||||||
// 模拟双击事件
|
// 模拟双击事件
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user