Compare commits

...
1 Commits
2 changed files with 39 additions and 5 deletions
@@ -19,7 +19,6 @@
&:fullscreen { &:fullscreen {
border-radius: 0; border-radius: 0;
background-color: var(--full-screen-bg, #ffffff);
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
@@ -54,7 +53,7 @@
height: var(--height, inherit); height: var(--height, inherit);
} }
.x-card.page-card { .x-card.page-card:not(.fullscreen) {
@include push-auto(); @include push-auto();
@include applyWidthHeight(); @include applyWidthHeight();
@include m-tb($d-l); @include m-tb($d-l);
@@ -22,7 +22,7 @@ export class XCardComponent extends XCardContainerComponent {
private ACTION_PROVIDER_SUBSCRIPTION: Subscription; private ACTION_PROVIDER_SUBSCRIPTION: Subscription;
// //
// Full Screen ... //#region Full Screen ...
private IS_FULLSCREEN: boolean = false; private IS_FULLSCREEN: boolean = false;
public set isFullscreen(v: boolean) { public set isFullscreen(v: boolean) {
// //
@@ -35,9 +35,21 @@ export class XCardComponent extends XCardContainerComponent {
return this.IS_FULLSCREEN; return this.IS_FULLSCREEN;
} }
//#endregion //#endregion
//#endregion
// //
//#region LifeCycles ... //#region LifeCycles ...
onInit() {
super.onInit();
//
// Listen for fullscreen change events (handles ESC key and browser UI)
document.addEventListener('fullscreenchange', this.fullscreenChangeHandler);
document.addEventListener('webkitfullscreenchange', this.fullscreenChangeHandler);
document.addEventListener('mozfullscreenchange', this.fullscreenChangeHandler);
document.addEventListener('MSFullscreenChange', this.fullscreenChangeHandler);
}
onChange(changeKeys: string[]) { onChange(changeKeys: string[]) {
super.onChange(changeKeys); super.onChange(changeKeys);
@@ -58,6 +70,12 @@ export class XCardComponent extends XCardContainerComponent {
// //
this.unregisterActionProvider(); this.unregisterActionProvider();
//
document.removeEventListener('fullscreenchange', this.fullscreenChangeHandler);
document.removeEventListener('webkitfullscreenchange', this.fullscreenChangeHandler);
document.removeEventListener('mozfullscreenchange', this.fullscreenChangeHandler);
document.removeEventListener('MSFullscreenChange', this.fullscreenChangeHandler);
} }
registerViewHandlers() { registerViewHandlers() {
@@ -119,7 +137,7 @@ export class XCardComponent extends XCardContainerComponent {
// //
this.isFullscreen = true; this.isFullscreen = true;
this.detectChanges(); this.detectChanges();
} catch {} } catch { }
} }
public async exitFullscreen() { public async exitFullscreen() {
@@ -138,7 +156,7 @@ export class XCardComponent extends XCardContainerComponent {
// //
this.isFullscreen = false; this.isFullscreen = false;
this.detectChanges(); this.detectChanges();
} catch {} } catch { }
} }
public async toggleFullscreen() { public async toggleFullscreen() {
@@ -211,6 +229,22 @@ export class XCardComponent extends XCardContainerComponent {
} }
//#endregion //#endregion
//
//#region Fullscreen ...
private fullscreenChangeHandler = () => {
//
const isFullscreen = !!(
document.fullscreenElement ||
(document as any).webkitFullscreenElement ||
(document as any).mozFullScreenElement ||
(document as any).msFullscreenElement
);
//
this.isFullscreen = isFullscreen;
this.detectChanges();
};
private canUseFullscreen(): boolean { private canUseFullscreen(): boolean {
return !!( return !!(
document.fullscreenEnabled || document.fullscreenEnabled ||
@@ -220,4 +254,5 @@ export class XCardComponent extends XCardContainerComponent {
); );
} }
//#endregion //#endregion
//#endregion
} }