From 18a3bc1d5b151613f909aa7e9b8539e2998625e4 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Sun, 16 Feb 2025 21:22:49 +0100 Subject: [PATCH] fix: scrollbar on thumbnails --- src/components/reader/components/NavigationBar.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/reader/components/NavigationBar.tsx b/src/components/reader/components/NavigationBar.tsx index b5b254d..57a1ca0 100644 --- a/src/components/reader/components/NavigationBar.tsx +++ b/src/components/reader/components/NavigationBar.tsx @@ -22,11 +22,21 @@ export const NavigationBar = ({ currentPage, }); + // Scroll à l'ouverture des contrôles et au changement de page useEffect(() => { if (showControls) { - scrollToActiveThumbnail(); + requestAnimationFrame(() => { + const thumbnail = document.getElementById(`thumbnail-${currentPage}`); + if (thumbnail) { + thumbnail.scrollIntoView({ + behavior: showControls ? "instant" : "smooth", + block: "nearest", + inline: "center", + }); + } + }); } - }, [showControls, currentPage, scrollToActiveThumbnail]); + }, [showControls, currentPage]); return (