mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add touch events on touch monitor
This commit is contained in:
parent
d08d3eccef
commit
aee7650d47
@ -21,6 +21,9 @@
|
|||||||
@mouseup.stop.prevent="onMouseUp"
|
@mouseup.stop.prevent="onMouseUp"
|
||||||
@mouseenter.stop.prevent="onMouseEnter"
|
@mouseenter.stop.prevent="onMouseEnter"
|
||||||
@mouseleave.stop.prevent="onMouseLeave"
|
@mouseleave.stop.prevent="onMouseLeave"
|
||||||
|
@touchmove.stop.prevent="onTouchHandler"
|
||||||
|
@touchstart.stop.prevent="onTouchHandler"
|
||||||
|
@touchend.stop.prevent="onTouchHandler"
|
||||||
/>
|
/>
|
||||||
<div v-if="!playing && playable" class="player-overlay" @click.stop.prevent="playAndUnmute">
|
<div v-if="!playing && playable" class="player-overlay" @click.stop.prevent="playAndUnmute">
|
||||||
<i class="fas fa-play-circle" />
|
<i class="fas fa-play-circle" />
|
||||||
@ -687,6 +690,35 @@
|
|||||||
}, 100)
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onTouchHandler(event: TouchEvent) {
|
||||||
|
let touches = event.changedTouches
|
||||||
|
let first = touches[0]
|
||||||
|
let type = ''
|
||||||
|
switch (event.type) {
|
||||||
|
case 'touchstart':
|
||||||
|
type = 'mousedown'
|
||||||
|
break
|
||||||
|
case 'touchmove':
|
||||||
|
type = 'mousemove'
|
||||||
|
break
|
||||||
|
case 'touchend':
|
||||||
|
type = 'mouseup'
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const simulatedEvent = new MouseEvent(type, {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
view: window,
|
||||||
|
screenX: first.screenX,
|
||||||
|
screenY: first.screenY,
|
||||||
|
clientX: first.clientX,
|
||||||
|
clientY: first.clientY,
|
||||||
|
})
|
||||||
|
first.target.dispatchEvent(simulatedEvent)
|
||||||
|
}
|
||||||
|
|
||||||
onMouseDown(e: MouseEvent) {
|
onMouseDown(e: MouseEvent) {
|
||||||
if (!this.hosting) {
|
if (!this.hosting) {
|
||||||
|
Loading…
Reference in New Issue
Block a user