Archived
2
0

rename func.

This commit is contained in:
Miroslav Šedivý 2021-12-04 21:47:52 +01:00
parent 15a8381f04
commit 7d2c3526b2

View File

@ -217,7 +217,7 @@
@Prop(Boolean) readonly hideControls!: boolean @Prop(Boolean) readonly hideControls!: boolean
private keyboard = GuacamoleKeyboard() private keyboard = GuacamoleKeyboard()
private observer = new ResizeObserver(this.onResise.bind(this)) private observer = new ResizeObserver(this.onResize.bind(this))
private focused = false private focused = false
private fullscreen = false private fullscreen = false
private startsMuted = true private startsMuted = true
@ -322,12 +322,12 @@
@Watch('width') @Watch('width')
onWidthChanged(width: number) { onWidthChanged(width: number) {
this.onResise() this.onResize()
} }
@Watch('height') @Watch('height')
onHeightChanged(height: number) { onHeightChanged(height: number) {
this.onResise() this.onResize()
} }
@Watch('volume') @Watch('volume')
@ -384,17 +384,17 @@
} }
mounted() { mounted() {
this._container.addEventListener('resize', this.onResise) this._container.addEventListener('resize', this.onResize)
this.onVolumeChanged(this.volume) this.onVolumeChanged(this.volume)
this.onMutedChanged(this.muted) this.onMutedChanged(this.muted)
this.onStreamChanged(this.stream) this.onStreamChanged(this.stream)
this.onResise() this.onResize()
this.observer.observe(this._component) this.observer.observe(this._component)
this._player.addEventListener('fullscreenchange', () => { this._player.addEventListener('fullscreenchange', () => {
this.fullscreen = document.fullscreenElement !== null this.fullscreen = document.fullscreenElement !== null
this.onResise() this.onResize()
}) })
this._video.addEventListener('canplaythrough', () => { this._video.addEventListener('canplaythrough', () => {
@ -513,7 +513,7 @@
try { try {
await this._video.play() await this._video.play()
this.onResise() this.onResize()
} catch (err: any) { } catch (err: any) {
this.$log.error(err) this.$log.error(err)
} }
@ -551,6 +551,10 @@
this.$accessor.remote.toggle() this.$accessor.remote.toggle()
} }
requestControl() {
this.$accessor.remote.request()
}
_elementRequestFullscreen(el: HTMLElement) { _elementRequestFullscreen(el: HTMLElement) {
if (typeof el.requestFullscreen === 'function') { if (typeof el.requestFullscreen === 'function') {
el.requestFullscreen() el.requestFullscreen()
@ -576,13 +580,13 @@
requestFullscreen() { requestFullscreen() {
// try to fullscreen player element // try to fullscreen player element
if (this._elementRequestFullscreen(this._player)) { if (this._elementRequestFullscreen(this._player)) {
this.onResise() this.onResize()
return return
} }
// fallback to fullscreen video itself (on mobile devices) // fallback to fullscreen video itself (on mobile devices)
if (this._elementRequestFullscreen(this._video)) { if (this._elementRequestFullscreen(this._video)) {
this.onResise() this.onResize()
return return
} }
} }
@ -590,7 +594,7 @@
requestPictureInPicture() { requestPictureInPicture() {
//@ts-ignore //@ts-ignore
this._video.requestPictureInPicture() this._video.requestPictureInPicture()
this.onResise() this.onResize()
} }
async onFocus() { async onFocus() {
@ -611,9 +615,10 @@
} }
} }
onMousePos(e: MouseEvent) { sendMousePos(e: MouseEvent) {
const { w, h } = this.$accessor.video.resolution const { w, h } = this.$accessor.video.resolution
const rect = this._overlay.getBoundingClientRect() const rect = this._overlay.getBoundingClientRect()
this.$client.sendData('mousemove', { this.$client.sendData('mousemove', {
x: Math.round((w / rect.width) * (e.clientX - rect.left)), x: Math.round((w / rect.width) * (e.clientX - rect.left)),
y: Math.round((h / rect.height) * (e.clientY - rect.top)), y: Math.round((h / rect.height) * (e.clientY - rect.top)),
@ -625,7 +630,6 @@
if (!this.hosting || this.locked) { if (!this.hosting || this.locked) {
return return
} }
this.onMousePos(e)
let x = e.deltaX let x = e.deltaX
let y = e.deltaY let y = e.deltaY
@ -648,6 +652,8 @@
x = Math.min(Math.max(x, -this.scroll), this.scroll) x = Math.min(Math.max(x, -this.scroll), this.scroll)
y = Math.min(Math.max(y, -this.scroll), this.scroll) y = Math.min(Math.max(y, -this.scroll), this.scroll)
this.sendMousePos(e)
if (!this.wheelThrottle) { if (!this.wheelThrottle) {
this.wheelThrottle = true this.wheelThrottle = true
this.$client.sendData('wheel', { x, y }) this.$client.sendData('wheel', { x, y })
@ -667,7 +673,7 @@
return return
} }
this.onMousePos(e) this.sendMousePos(e)
this.$client.sendData('mousedown', { key: e.button + 1 }) this.$client.sendData('mousedown', { key: e.button + 1 })
} }
@ -676,7 +682,7 @@
return return
} }
this.onMousePos(e) this.sendMousePos(e)
this.$client.sendData('mouseup', { key: e.button + 1 }) this.$client.sendData('mouseup', { key: e.button + 1 })
} }
@ -685,7 +691,7 @@
return return
} }
this.onMousePos(e) this.sendMousePos(e)
} }
onMouseEnter(e: MouseEvent) { onMouseEnter(e: MouseEvent) {
@ -715,7 +721,7 @@
this.focused = false this.focused = false
} }
onResise() { onResize() {
let height = 0 let height = 0
if (!this.fullscreen) { if (!this.fullscreen) {
const { offsetWidth, offsetHeight } = this._component const { offsetWidth, offsetHeight } = this._component