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.hash = ""
|
||||||
thisUrl.search = ""
|
thisUrl.search = ""
|
||||||
const targetUrl = new URL(link.href)
|
const targetUrl = new URL(link.href)
|
||||||
let hash = decodeURIComponent(targetUrl.hash)
|
const hash = decodeURIComponent(targetUrl.hash)
|
||||||
targetUrl.hash = ""
|
targetUrl.hash = ""
|
||||||
targetUrl.search = ""
|
targetUrl.search = ""
|
||||||
|
|
||||||
@ -87,8 +87,6 @@ async function mouseEnterHandler(
|
|||||||
const targetID = `popover-${el.id}`
|
const targetID = `popover-${el.id}`
|
||||||
el.id = targetID
|
el.id = targetID
|
||||||
})
|
})
|
||||||
const targetLink = hash.startsWith("#popover") ? hash : `#popover-${hash.slice(1)}`
|
|
||||||
hash = targetLink
|
|
||||||
const elts = [...html.getElementsByClassName("popover-hint")]
|
const elts = [...html.getElementsByClassName("popover-hint")]
|
||||||
if (elts.length === 0) return
|
if (elts.length === 0) return
|
||||||
|
|
||||||
@ -99,7 +97,8 @@ async function mouseEnterHandler(
|
|||||||
link.appendChild(popoverElement)
|
link.appendChild(popoverElement)
|
||||||
|
|
||||||
if (hash !== "") {
|
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) {
|
if (heading) {
|
||||||
// leave ~12px of buffer when scrolling to a heading
|
// leave ~12px of buffer when scrolling to a heading
|
||||||
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
|
popoverInner.scroll({ top: heading.offsetTop - 12, behavior: "instant" })
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user