Skip to content

Commit

Permalink
fix(portal): behavior between html getinfo and animation offset x
Browse files Browse the repository at this point in the history
  • Loading branch information
pelord committed Sep 17, 2021
1 parent b761136 commit 7c5d767
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/portal/portal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
[map]="map"
[store]="queryStore"
[hasFeatureEmphasisOnSelection]="hasFeatureEmphasisOnSelection"
[@toastPanelOffsetX]="(isMobile() || !isLandscape()) ? undefined : getToastPanelExtent()"
[@toastPanelOffsetX]="toastPanelOffsetX$ | async"
[@toastPanelOffsetY]="getToastPanelOffsetY()"
[@toastPanelMobileSidenav]="(isMobile() && sidenavOpened) || (isTablet() && isPortrait() && sidenavOpened)"
[opened]="toastPanelOpened"
Expand Down
35 changes: 33 additions & 2 deletions src/app/pages/portal/portal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ElementRef
} from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Subscription, of, BehaviorSubject } from 'rxjs';
import { Subscription, of, BehaviorSubject, combineLatest } from 'rxjs';
import { debounceTime, take, pairwise, skipWhile } from 'rxjs/operators';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import MapBrowserEvent from 'ol/MapBrowserEvent';
Expand Down Expand Up @@ -107,6 +107,8 @@ import olFormatGeoJSON from 'ol/format/GeoJSON';
]
})
export class PortalComponent implements OnInit, OnDestroy {
public toastPanelOffsetX$: BehaviorSubject<string> = new BehaviorSubject(undefined);
public sidenavOpened$: BehaviorSubject<boolean> = new BehaviorSubject(false);
public minSearchTermLength = 2;
public hasExpansionPanel = false;
public hasGeolocateButton = true;
Expand All @@ -130,7 +132,7 @@ export class PortalComponent implements OnInit, OnDestroy {
readonly workspaceMaximize$: BehaviorSubject<boolean> = new BehaviorSubject(
this.storageService.get('workspaceMaximize') as boolean
);
public sidenavOpened = false;

public searchBarTerm = '';
public onSettingsChange$ = new BehaviorSubject<boolean>(undefined);
public termDefinedInUrl = false;
Expand All @@ -146,6 +148,7 @@ export class PortalComponent implements OnInit, OnDestroy {

private context$$: Subscription;
private openSidenav$$: Subscription;
private sidenavMediaAndOrientation$$: Subscription;

public igoSearchPointerSummaryEnabled: boolean;

Expand All @@ -168,6 +171,14 @@ export class PortalComponent implements OnInit, OnDestroy {
return this.mapState.map;
}

get sidenavOpened(): boolean {
return this.sidenavOpened$.value;
}

set sidenavOpened(value: boolean) {
this.sidenavOpened$.next(value);
}

get auth(): AuthOptions {
return this.configService.getConfig('auth') || [];
}
Expand Down Expand Up @@ -441,6 +452,25 @@ export class PortalComponent implements OnInit, OnDestroy {
this.menuButtonClass = this.getClassMenuButton();
}
);

this.sidenavMediaAndOrientation$$ =
combineLatest([
this.sidenavOpened$,
this.mediaService.media$,
this.mediaService.orientation$]
).pipe(
debounceTime(50)
).subscribe((sidenavMediaAndOrientation: [boolean, string, string]) => {
this.computeToastPanelOffsetX();
});
}

computeToastPanelOffsetX() {
if (this.isMobile() || !this.isLandscape()) {
this.toastPanelOffsetX$.next(undefined);
} else {
this.toastPanelOffsetX$.next(this.getToastPanelExtent());
}
}

getClassMenuButton() {
Expand Down Expand Up @@ -534,6 +564,7 @@ export class PortalComponent implements OnInit, OnDestroy {
this.activeWidget$$.unsubscribe();
this.openSidenav$$.unsubscribe();
this.workspaceMaximize$$.map(f => f.unsubscribe());
this.sidenavMediaAndOrientation$$.unsubscribe();
}

/**
Expand Down

0 comments on commit 7c5d767

Please sign in to comment.