mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add drag and drop event handler.
This commit is contained in:
parent
9455fda582
commit
dea3378cb0
@ -12,6 +12,7 @@
|
||||
:implicitControl="state.control.implicit_hosting && state.members[state.member_id].profile.can_host"
|
||||
@implicit-control-request="websocket.send('control/request')"
|
||||
@implicit-control-release="websocket.send('control/release')"
|
||||
@drop-files="api.room.uploadDrop($event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,6 +11,10 @@
|
||||
@mouseup.stop.prevent="onMouseUp"
|
||||
@mouseenter.stop.prevent="onMouseEnter"
|
||||
@mouseleave.stop.prevent="onMouseLeave"
|
||||
@dragenter.stop.prevent="onDrag"
|
||||
@dragleave.stop.prevent="onDrag"
|
||||
@dragover.stop.prevent="onDrag"
|
||||
@drop.stop.prevent="onDrop"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@ -95,13 +99,17 @@
|
||||
// Guacamole Keyboard does not provide destroy functions
|
||||
}
|
||||
|
||||
setMousePos(e: MouseEvent) {
|
||||
getMousePos(clientX: number, clientY: number) {
|
||||
const rect = this._overlay.getBoundingClientRect()
|
||||
|
||||
this.webrtc.send('mousemove', {
|
||||
x: Math.round((this.screenWidth / rect.width) * (e.clientX - rect.left)),
|
||||
y: Math.round((this.screenHeight / rect.height) * (e.clientY - rect.top)),
|
||||
})
|
||||
return {
|
||||
x: Math.round((this.screenWidth / rect.width) * (clientX - rect.left)),
|
||||
y: Math.round((this.screenHeight / rect.height) * (clientY - rect.top)),
|
||||
}
|
||||
}
|
||||
|
||||
setMousePos(e: MouseEvent) {
|
||||
this.webrtc.send('mousemove', this.getMousePos(e.clientX, e.clientY))
|
||||
}
|
||||
|
||||
onWheel(e: WheelEvent) {
|
||||
@ -186,6 +194,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
onDrag(e: DragEvent) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
}
|
||||
|
||||
onDrop(e: DragEvent) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
let dt = e.dataTransfer
|
||||
if (!dt) return
|
||||
|
||||
let files = [...dt.files]
|
||||
if (!files) return
|
||||
|
||||
this.$emit('drop-files', { ...this.getMousePos(e.clientX, e.clientY), files })
|
||||
}
|
||||
|
||||
isRequesting = false
|
||||
@Watch('isControling')
|
||||
onControlChange(isControling: boolean) {
|
||||
|
Loading…
Reference in New Issue
Block a user