mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
Let it const
This commit is contained in:
parent
3ef20bfb58
commit
7c46da37a3
@ -34,7 +34,7 @@ async function mouseEnterHandler(
|
||||
thisUrl.hash = ""
|
||||
thisUrl.search = ""
|
||||
const targetUrl = new URL(link.href)
|
||||
let hash = decodeURIComponent(targetUrl.hash)
|
||||
const hash = decodeURIComponent(targetUrl.hash)
|
||||
targetUrl.hash = ""
|
||||
targetUrl.search = ""
|
||||
|
||||
@ -87,8 +87,6 @@ async function mouseEnterHandler(
|
||||
const targetID = `popover-${el.id}`
|
||||
el.id = targetID
|
||||
})
|
||||
const targetLink = hash.startsWith("#popover") ? hash : `#popover-${hash.slice(1)}`
|
||||
hash = targetLink
|
||||
const elts = [...html.getElementsByClassName("popover-hint")]
|
||||
if (elts.length === 0) return
|
||||
|
||||
@ -99,7 +97,8 @@ async function mouseEnterHandler(
|
||||
link.appendChild(popoverElement)
|
||||
|
||||
if (hash !== "") {
|
||||
const heading = popoverInner.querySelector(hash) as HTMLElement | null
|
||||
const targetAnchor = hash.startsWith("#popover") ? hash : `#popover-${hash.slice(1)}`
|
||||
const heading = popoverInner.querySelector(targetAnchor) as HTMLElement | null
|
||||
if (heading) {
|
||||
// leave ~12px of buffer when scrolling to a heading
|
||||
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user