Skip to content

Commit

Permalink
add touch events on touch monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Urbanek committed Mar 27, 2023
1 parent d08d3ec commit aee7650
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions client/src/components/video.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
@mouseup.stop.prevent="onMouseUp"
@mouseenter.stop.prevent="onMouseEnter"
@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">
<i class="fas fa-play-circle" />
Expand Down Expand Up @@ -687,6 +690,35 @@
}, 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) {
if (!this.hosting) {
Expand Down

0 comments on commit aee7650

Please sign in to comment.