Fixed sidebar jitter by switching to sticky positioning

This commit is contained in:
squidfunk
2020-04-26 13:17:45 +02:00
committed by Martin Donath
parent 9d89ad337d
commit 7eb6cb6536
17 changed files with 26 additions and 96 deletions

View File

@@ -43,10 +43,8 @@ import { Main } from "../../../main"
import { Sidebar } from "../_"
import {
resetSidebarHeight,
resetSidebarLock,
resetSidebarOffset,
setSidebarHeight,
setSidebarLock,
setSidebarOffset
} from "../set"
@@ -131,7 +129,6 @@ export function applySidebar(
withLatestFrom(header$),
tap(([{ height, lock }, { height: offset }]) => {
setSidebarHeight(el, height)
setSidebarLock(el, lock)
/* Set offset in locked state depending on header height */
if (lock)
@@ -147,7 +144,6 @@ export function applySidebar(
finalize(() => {
resetSidebarOffset(el)
resetSidebarHeight(el)
resetSidebarLock(el)
})
)
}

View File

@@ -71,28 +71,3 @@ export function resetSidebarHeight(
): void {
el.style.height = ""
}
/* ------------------------------------------------------------------------- */
/**
* Set sidebar lock
*
* @param el - Sidebar element
* @param value - Whether the sidebar is locked
*/
export function setSidebarLock(
el: HTMLElement, value: boolean
): void {
el.setAttribute("data-md-state", value ? "lock" : "")
}
/**
* Reset sidebar lock
*
* @param el - Sidebar element
*/
export function resetSidebarLock(
el: HTMLElement
): void {
el.removeAttribute("data-md-state")
}