Replaced getComputedStyle with bounding box values

This commit is contained in:
squidfunk
2020-03-15 16:19:36 +01:00
parent 9f069ad47e
commit 825eeae70c
14 changed files with 28 additions and 40 deletions

View File

@@ -25,11 +25,11 @@ import {
Observable,
animationFrameScheduler,
combineLatest,
of,
pipe
} from "rxjs"
import {
distinctUntilChanged,
distinctUntilKeyChanged,
finalize,
map,
observeOn,
@@ -90,19 +90,11 @@ interface ApplyOptions {
export function watchSidebar(
el: HTMLElement, { main$, viewport$ }: WatchOptions
): Observable<Sidebar> {
/* Adjust for internal main area offset */
const adjust$ = viewport$
.pipe(
distinctUntilKeyChanged("size"),
map(() => parseFloat(
getComputedStyle(el.parentElement!)
.getPropertyValue("padding-top")
)),
distinctUntilChanged()
)
const inner = el.parentElement!
const outer = inner.parentElement!
/* Compute the sidebar's available height */
const adjust$ = of(inner.offsetTop - outer.offsetTop)
const height$ = viewport$
.pipe(
withLatestFrom(adjust$, main$),