chore: rename function to enhance readability

This commit is contained in:
tuscan-blue 2025-04-05 02:34:54 +08:00
parent 71823c5f89
commit 9ac43636e1

View File

@ -7,7 +7,7 @@ async function mouseEnterHandler(
this: HTMLAnchorElement, this: HTMLAnchorElement,
{ clientX, clientY }: { clientX: number; clientY: number }, { clientX, clientY }: { clientX: number; clientY: number },
) { ) {
inActivePopover() clearActivePopover()
const link = this const link = this
link.id = link.innerText link.id = link.innerText
@ -110,7 +110,7 @@ async function mouseEnterHandler(
} }
} }
function inActivePopover() { function clearActivePopover() {
const allPopoverElements = document.querySelectorAll(".popover") const allPopoverElements = document.querySelectorAll(".popover")
if (allPopoverElements) { if (allPopoverElements) {
allPopoverElements.forEach((popoverElement) => allPopoverElements.forEach((popoverElement) =>
@ -122,11 +122,11 @@ function inActivePopover() {
document.addEventListener("nav", () => { document.addEventListener("nav", () => {
const links = [...document.getElementsByClassName("internal")] as HTMLAnchorElement[] const links = [...document.getElementsByClassName("internal")] as HTMLAnchorElement[]
for (const link of links) { for (const link of links) {
link.addEventListener("mouseleave", inActivePopover) link.addEventListener("mouseleave", clearActivePopover)
link.addEventListener("mouseenter", mouseEnterHandler) link.addEventListener("mouseenter", mouseEnterHandler)
window.addCleanup(() => { window.addCleanup(() => {
link.removeEventListener("mouseenter", mouseEnterHandler) link.removeEventListener("mouseenter", mouseEnterHandler)
link.removeEventListener("mouseleave", inActivePopover) link.removeEventListener("mouseleave", clearActivePopover)
}) })
} }
}) })