Skip to content

Commit

Permalink
fix(screen-orientation): Viewport fix initial value (#952)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Oct 14, 2024
1 parent 8c1cba3 commit ab6d632
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libs/screen-orientation/src/viewport.service.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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}),
Expand Down

0 comments on commit ab6d632

Please sign in to comment.