Improved rendering performance by combining upstream observables

This commit is contained in:
squidfunk
2020-03-17 11:10:51 +01:00
parent bfe214966a
commit dd2f2c879a
18 changed files with 84 additions and 100 deletions

View File

@@ -93,10 +93,13 @@ export function watchViewport(): Observable<Viewport> {
export function watchViewportAt(
el: HTMLElement, { header$, viewport$ }: WatchAtOptions
): Observable<Viewport> {
const offset$ = combineLatest([
viewport$.pipe(distinctUntilKeyChanged("size")),
header$
])
const size$ = viewport$
.pipe(
distinctUntilKeyChanged("size")
)
/* Compute element offset */
const offset$ = combineLatest([size$, header$])
.pipe(
map((): ViewportOffset => ({
x: el.offsetLeft,