From ecd3635a3d95577329a3717fa9ba8523635fd01b Mon Sep 17 00:00:00 2001 From: the3ash <24548223+the3ash@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:40:12 +0800 Subject: [PATCH] feat(post): add highlight animation on footnote nav --- src/components/widgets/FootnoteScroll.astro | 11 +++++++++++ src/styles/post.css | 19 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/components/widgets/FootnoteScroll.astro b/src/components/widgets/FootnoteScroll.astro index 7afba67..baba037 100644 --- a/src/components/widgets/FootnoteScroll.astro +++ b/src/components/widgets/FootnoteScroll.astro @@ -19,6 +19,17 @@ window.scrollTo({ top: targetPosition }) + + // Highlight effect + const highlightTarget = target.closest('cite') || target.closest('sup') || target + highlightTarget.classList.add('footnote-highlight') + highlightTarget.addEventListener( + 'animationend', + () => { + highlightTarget.classList.remove('footnote-highlight') + }, + { once: true } + ) }) }) } diff --git a/src/styles/post.css b/src/styles/post.css index ed245b7..6d8db0b 100644 --- a/src/styles/post.css +++ b/src/styles/post.css @@ -450,7 +450,7 @@ opacity: 0.875; text-decoration: none; transition: color 0.2s ease-out; - padding-right: 0.5em; + padding-right: 0.125em; } .prose [data-footnote-ref]:hover, @@ -458,6 +458,23 @@ color: var(--text-primary); } +/* Footnote highlight animation */ +.prose .footnotes li.footnote-highlight, +.prose sup.footnote-highlight, +.prose cite.footnote-highlight { + animation: footnote-highlight 1.35s ease-out; +} + +@keyframes footnote-highlight { + 0%, + 87% { + background-color: var(--selection); + } + 100% { + background-color: transparent; + } +} + /* Code blocks */ .prose pre { background-color: var(--astro-code-background); -- knotmirror 0.0.1