mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-23 06:13:38 -04:00
Jump to anchor inside details tag and refactor tablet styles
This commit is contained in:
@@ -277,6 +277,28 @@ export function initialize(config: unknown) {
|
||||
)
|
||||
.subscribe()
|
||||
|
||||
// TODO: patch details!
|
||||
|
||||
/* Open details after anchor jump */
|
||||
merge(hash$, of(location.hash)) // getLocationHash
|
||||
.subscribe(hash => {
|
||||
const el = getElement(hash)
|
||||
console.log("jump to", hash)
|
||||
if (typeof el !== "undefined") {
|
||||
const parent = el.closest("details")
|
||||
if (parent && !parent.open) { // only if it is not open!
|
||||
parent.open = true
|
||||
|
||||
/* Hack: force reload for repositioning */ // TODO. what happens here!?
|
||||
location.hash = "" // reset
|
||||
requestAnimationFrame(() => {
|
||||
location.hash = hash // tslint:disable-line
|
||||
})
|
||||
// TODO: setLocationHash() + forceLocationHashChange
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Scroll lock
|
||||
const toggle$ = useToggle("search")
|
||||
combineLatest([
|
||||
@@ -300,6 +322,8 @@ export function initialize(config: unknown) {
|
||||
)
|
||||
.subscribe()
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
// General keyboard handlers
|
||||
keyboard$
|
||||
.pipe(
|
||||
|
||||
Reference in New Issue
Block a user