Jump to anchor inside details tag and refactor tablet styles

This commit is contained in:
squidfunk
2020-02-18 15:39:36 +01:00
parent b2654777b8
commit dee75ccfbb
10 changed files with 56 additions and 33 deletions

View File

@@ -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(