diff --git a/libs/screen-orientation/src/viewport.service.ts b/libs/screen-orientation/src/viewport.service.ts index 9449f973..aa869178 100644 --- a/libs/screen-orientation/src/viewport.service.ts +++ b/libs/screen-orientation/src/viewport.service.ts @@ -1,6 +1,15 @@ import {inject, Injectable} from '@angular/core'; import {WINDOW} from '@ng-web-apis/common'; -import {EMPTY, filter, fromEvent, map, merge, Observable, shareReplay} from 'rxjs'; +import { + EMPTY, + filter, + fromEvent, + map, + merge, + Observable, + shareReplay, + startWith, +} from 'rxjs'; @Injectable({ providedIn: 'root', @@ -14,6 +23,7 @@ export class ViewportService extends Observable<VisualViewport> { fromEvent(this.visualViewport, 'scroll'), fromEvent(this.visualViewport, 'scrollend'), ).pipe( + startWith(null), map(() => this.visualViewport), filter(Boolean), shareReplay({bufferSize: 1, refCount: true}),