From a4c15ecc0e92ed614a0d2d4c1a1d6562b757b35d Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 5 Oct 2025 02:08:51 +0100 Subject: [PATCH] feat: add pulsing animation when scrolling to highlight - Replace brightness change with subtle pulse animation - Pulse twice over 1.5 seconds with scale and glow effects - Scale slightly (1.02x) and increase shadow glow - More elegant visual feedback than color change - Easier to spot without being jarring The highlight now pulses twice when clicked from the sidebar, making it easy to see where you've jumped to. --- src/components/ContentPanel.tsx | 8 ++++---- src/index.css | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index 76f80d76..6bf73346 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -44,12 +44,12 @@ const ContentPanel: React.FC = ({ console.log('📍 Scrolling to highlight in article:', selectedHighlightId.slice(0, 8)) markElement.scrollIntoView({ behavior: 'smooth', block: 'center' }) - // Temporarily enhance the highlight to show it's selected - const originalBackground = (markElement as HTMLElement).style.background - ;(markElement as HTMLElement).style.background = 'rgba(255, 255, 0, 0.7)' + // Add pulsing animation to show it's selected + const htmlElement = markElement as HTMLElement + htmlElement.classList.add('highlight-pulse') setTimeout(() => { - (markElement as HTMLElement).style.background = originalBackground + htmlElement.classList.remove('highlight-pulse') }, 1500) } else { console.log('⚠️ Could not find mark element for highlight:', selectedHighlightId.slice(0, 8)) diff --git a/src/index.css b/src/index.css index 604b6fdb..3d1bb1e7 100644 --- a/src/index.css +++ b/src/index.css @@ -1374,6 +1374,29 @@ body { box-shadow: 0 0 12px rgba(255, 255, 0, 0.3); } +.content-highlight.highlight-pulse { + animation: highlight-pulse-animation 1.5s ease-in-out; +} + +@keyframes highlight-pulse-animation { + 0%, 100% { + box-shadow: 0 0 8px rgba(255, 255, 0, 0.2); + transform: scale(1); + } + 25% { + box-shadow: 0 0 20px rgba(255, 255, 0, 0.6); + transform: scale(1.02); + } + 50% { + box-shadow: 0 0 8px rgba(255, 255, 0, 0.2); + transform: scale(1); + } + 75% { + box-shadow: 0 0 20px rgba(255, 255, 0, 0.6); + transform: scale(1.02); + } +} + .reader-html .content-highlight, .reader-markdown .content-highlight { color: inherit;