提交 e7e22d72 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat: touchcancel

上级 577ee28b
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<view <view
class="target" class="target"
@touchstart="onTouchStart" @touchstart="onTouchStart"
@touchcancel="onTouchCancel"
@touchmove="onTouchMove" @touchmove="onTouchMove"
@touchend="onTouchEnd" @touchend="onTouchEnd"
@tap="onTap" @tap="onTap"
...@@ -45,6 +46,37 @@ ...@@ -45,6 +46,37 @@
> >
</template> </template>
</view> </view>
<view v-if="touchCancelEvent !== null">
<text class="title1">touchCancel Event: </text>
<text class="title2">touches: </text>
<template
v-for="(touch, index) in touchCancelEvent!.touches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template>
<text class="title2 uni-common-mt">changedTouches: </text>
<template
v-for="(touch, index) in touchCancelEvent!.changedTouches"
:key="index"
>
<text class="title3">touch[{{ index }}]:</text>
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
<text
>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text
>
<text
>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text
>
</template>
</view>
<view v-if="touchMoveEvent !== null"> <view v-if="touchMoveEvent !== null">
<text class="title1">touchMove Event: </text> <text class="title1">touchMove Event: </text>
<text class="title2">touches: </text> <text class="title2">touches: </text>
...@@ -161,6 +193,7 @@ export default { ...@@ -161,6 +193,7 @@ export default {
title: 'general-event', title: 'general-event',
onTouchStartTime: 0, onTouchStartTime: 0,
touchStartEvent: null as TouchEvent | null, touchStartEvent: null as TouchEvent | null,
touchCancelEvent: null as TouchEvent | null,
onTouchMoveTime: 0, onTouchMoveTime: 0,
touchMoveEvent: null as TouchEvent | null, touchMoveEvent: null as TouchEvent | null,
onTouchEndTime: 0, onTouchEndTime: 0,
...@@ -179,6 +212,10 @@ export default { ...@@ -179,6 +212,10 @@ export default {
this.onTouchStartTime = Date.now() this.onTouchStartTime = Date.now()
console.log('onTouchStart') console.log('onTouchStart')
}, },
onTouchCancel(e: TouchEvent){
this.touchCancelEvent = e
console.log('onTouchCancel')
},
onTouchMove(e: TouchEvent){ onTouchMove(e: TouchEvent){
this.touchMoveEvent = e this.touchMoveEvent = e
this.onTouchMoveTime = Date.now() this.onTouchMoveTime = Date.now()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册