diff --git a/src/app.vue b/src/app.vue index 784c510c..6f5acd71 100644 --- a/src/app.vue +++ b/src/app.vue @@ -83,9 +83,9 @@ - - screen.is_fullscreen - {{ neko.state.screen.is_fullscreen }} + + screen.fullscreen + member.id diff --git a/src/components/canvas.vue b/src/components/canvas.vue index 3ad1c843..eb0664de 100644 --- a/src/components/canvas.vue +++ b/src/components/canvas.vue @@ -105,7 +105,7 @@ rate: 30, }, configurations: [], - is_fullscreen: false, + fullscreen: false, }, member: { id: null, @@ -151,6 +151,15 @@ this.onResize() } + @Watch('state.screen.fullscreen') + onScreenFullscreenChanged() { + if (document.fullscreenElement !== null) { + document.exitFullscreen() + } else { + this._component.requestFullscreen() + } + } + public control = { request: () => { this.websocket.send('control/request') @@ -200,6 +209,11 @@ Vue.set(this.state.member, 'is_controlling', id != null && id === this.state.member.id) }) + this._component.addEventListener('fullscreenchange', () => { + Vue.set(this.state.screen, 'fullscreen', document.fullscreenElement !== null) + this.onResize() + }) + // Video VideoRegister(this.video, this.state.video) diff --git a/src/types/state.ts b/src/types/state.ts index 736b918b..713f3662 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -47,7 +47,7 @@ export interface Scroll { export interface Screen { size: ScreenSize configurations: ScreenSize[] - is_fullscreen: boolean + fullscreen: boolean } export interface ScreenSize {