Skip to content

Commit

Permalink
Merge pull request #622 from AiursoftWeb/probeFile
Browse files Browse the repository at this point in the history
fix: prevent blocking items when using ios safari
  • Loading branch information
Anduin2017 authored Aug 8, 2019
2 parents 258f846 + 245314b commit 3c62092
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app/Controllers/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
})
Expand Down
2 changes: 2 additions & 0 deletions src/app/Views/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
</div>
<div id="contentWrapper" class="content-wrapper" *ngIf="!(route.isActive('/home', false) && homeService.wideScreenEnabled)"
[class.in-widescreen]="homeService.wideScreenEnabled">
<div style="height: 50px" *ngIf="iosHeightFix"></div>
<router-outlet></router-outlet>
<div style="height: 50px" *ngIf="iosHeightFix"></div>
</div>
<!-- Show an empty component when no reasonable component to show. -->
<div class="content-empty" *ngIf="route.isActive('/home', false) && homeService.wideScreenEnabled && messageService.me">
Expand Down

0 comments on commit 3c62092

Please sign in to comment.