mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-08-01 02:08:46 -04:00
Improved rendering performance by combining upstream observables
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user