Improved flow of observables/emissions

This commit is contained in:
squidfunk
2020-03-16 14:59:59 +01:00
parent 47aa47ee4c
commit 653d535a22
16 changed files with 86 additions and 93 deletions

View File

@@ -93,9 +93,11 @@ export function watchViewport(): Observable<Viewport> {
export function watchViewportAt(
el: HTMLElement, { header$, viewport$ }: WatchAtOptions
): Observable<Viewport> {
const offset$ = viewport$
const offset$ = combineLatest([
viewport$.pipe(distinctUntilKeyChanged("size")),
header$
])
.pipe(
distinctUntilKeyChanged("size"),
map((): ViewportOffset => ({
x: el.offsetLeft,
y: el.offsetTop