From 245314bef2f025d7c8e10c9322a2e70e2859e881 Mon Sep 17 00:00:00 2001 From: EdgeNeko Date: Thu, 8 Aug 2019 18:41:33 +0800 Subject: [PATCH] fix: prevent blocking items when using ios safari --- src/app/Controllers/app.component.ts | 10 +++++++++- src/app/Views/app.html | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/Controllers/app.component.ts b/src/app/Controllers/app.component.ts index a48d1737..fd3a842a 100644 --- a/src/app/Controllers/app.component.ts +++ b/src/app/Controllers/app.component.ts @@ -16,6 +16,8 @@ import { MessageService } from '../Services/MessageService'; export class AppComponent implements OnInit, AfterViewInit { + public iosHeightFix = false; + constructor( private initService: InitService, private elementRef: ElementRef, @@ -31,6 +33,13 @@ export class AppComponent implements OnInit, AfterViewInit { Swal.close(); } + @HostListener('window:resize') + onResize() { + // in safari and the address bar is shown... + this.iosHeightFix = window.navigator.platform && /iP(ad|hone|od)/.test(window.navigator.platform) && + document.body.scrollHeight - window.innerHeight >= 50; + } + @HostListener('window:load', []) onLoad() { if ('Notification' in window && 'serviceWorker' in navigator) { @@ -65,7 +74,6 @@ export class AppComponent implements OnInit, AfterViewInit { // disable body scroll for ios if (window.navigator.platform && /iP(ad|hone|od)/.test(window.navigator.platform)) { this.homeService.updateIosDisableScroll(); - new MutationObserver(() => { this.homeService.updateIosDisableScroll(); }) diff --git a/src/app/Views/app.html b/src/app/Views/app.html index 802a4a70..025e6d2d 100644 --- a/src/app/Views/app.html +++ b/src/app/Views/app.html @@ -5,7 +5,9 @@
+
+