From 80bb49d77d185ba2cc82b871744232456e9905fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 8 Jun 2021 12:01:15 +0200 Subject: [PATCH] MOBILE-3771 h5p: Hide menu bar on landscape --- .../mod/h5pactivity/components/index/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index fe46478e2..0f76adba3 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -45,6 +45,8 @@ import { } from '../../services/h5pactivity-sync'; import { CoreFileHelper } from '@services/file-helper'; import { AddonModH5PActivityModuleHandlerService } from '../../services/handlers/module'; +import { CoreMainMenuPage } from '@features/mainmenu/pages/menu/menu'; +import { Platform } from '@singletons'; /** * Component that displays an H5P activity entry page. @@ -83,8 +85,10 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv protected site: CoreSite; protected observer?: CoreEventObserver; protected messageListenerFunction: (event: MessageEvent) => Promise; + protected resizeFunction: () => void; constructor( + protected mainMenuPage: CoreMainMenuPage, protected content?: IonContent, @Optional() courseContentsPage?: CoreCourseContentsPage, ) { @@ -96,6 +100,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv // Listen for messages from the iframe. this.messageListenerFunction = this.onIframeMessage.bind(this); window.addEventListener('message', this.messageListenerFunction); + this.resizeFunction = this.contentResized.bind(this); } /** @@ -366,6 +371,9 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv AddonModH5PActivity.logView(this.h5pActivity!.id, this.h5pActivity!.name, this.siteId); CoreCourse.checkModuleCompletion(this.courseId, this.module.completiondata); + + window.addEventListener('resize', this.contentResized.bind(this)); + this.contentResized(); } /** @@ -480,6 +488,13 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv } } + /** + * On content resize, change visibility of the main menu: show on portrait and hide on landscape. + */ + contentResized(): void { + this.mainMenuPage.changeVisibility(Platform.isPortrait()); + } + /** * Component destroyed. */ @@ -488,6 +503,10 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv this.observer?.off(); window.removeEventListener('message', this.messageListenerFunction); + + if (this.playing) { + window.removeEventListener('resize', this.resizeFunction); + } } }