From 73552160347870446dcee46a620ccc753089e6e7 Mon Sep 17 00:00:00 2001 From: Ehsan Rezaei Date: Wed, 31 May 2023 13:12:09 +0200 Subject: [PATCH] [AAE-14759] Fixed image viewer when going to full screen mode (#8609) --- .../viewer/components/img-viewer.component.spec.ts | 11 +++++++++++ .../src/lib/viewer/components/img-viewer.component.ts | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/lib/core/src/lib/viewer/components/img-viewer.component.spec.ts b/lib/core/src/lib/viewer/components/img-viewer.component.spec.ts index 55e72d0521..fe897a48c9 100644 --- a/lib/core/src/lib/viewer/components/img-viewer.component.spec.ts +++ b/lib/core/src/lib/viewer/components/img-viewer.component.spec.ts @@ -369,6 +369,17 @@ describe('Test Img viewer component ', () => { expect(component.isSaving.emit).toHaveBeenCalledWith(true); expect(component.isSaving.emit).toHaveBeenCalledWith(false); })); + + it('should reset the viewer after going to full screen mode', () => { + Object.defineProperty(document, 'fullscreenElement', { + value: true + }); + spyOn(component, 'reset'); + + document.dispatchEvent(new Event('fullscreenchange')); + + expect(component.reset).toHaveBeenCalled(); + }); }); }); diff --git a/lib/core/src/lib/viewer/components/img-viewer.component.ts b/lib/core/src/lib/viewer/components/img-viewer.component.ts index f5d15f0b71..3ca3aabf69 100644 --- a/lib/core/src/lib/viewer/components/img-viewer.component.ts +++ b/lib/core/src/lib/viewer/components/img-viewer.component.ts @@ -141,6 +141,13 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy { } } + @HostListener('document:fullscreenchange') + fullScreenChangeHandler() { + if(document.fullscreenElement) { + this.reset(); + } + } + ngOnChanges(changes: SimpleChanges) { const blobFile = changes['blobFile']; if (blobFile && blobFile.currentValue) {