From ab6d63241cecea7471b2e34416037093419d834a Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Mon, 14 Oct 2024 16:40:23 +0400 Subject: [PATCH] fix(screen-orientation): `Viewport` fix initial value (#952) --- libs/screen-orientation/src/viewport.service.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 { fromEvent(this.visualViewport, 'scroll'), fromEvent(this.visualViewport, 'scrollend'), ).pipe( + startWith(null), map(() => this.visualViewport), filter(Boolean), shareReplay({bufferSize: 1, refCount: true}),