From eb99d14b6e220a35422cc59afab17e599e34874c Mon Sep 17 00:00:00 2001 From: The Daniel Date: Thu, 30 Apr 2026 13:51:27 -0400 Subject: [PATCH] fix(carousel): reverse slide direction on prev arrow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The featured-market carousel always animated content in from the right. Clicking the back arrow advanced the index backward but visually slid the new card the wrong way. Track direction in the store so the prev arrow uses a mirrored keyframe (-80% → 0) while auto-advance and the next arrow keep the original direction. --- src/components/home/FeaturedMarket.tsx | 10 ++++++++-- src/components/home/HomePage.tsx | 1 + src/store/index.ts | 6 ++++++ src/style.css | 17 ++++++++++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/components/home/FeaturedMarket.tsx b/src/components/home/FeaturedMarket.tsx index 0b2bdaec..22a7ecbd 100644 --- a/src/components/home/FeaturedMarket.tsx +++ b/src/components/home/FeaturedMarket.tsx @@ -122,6 +122,7 @@ export default function FeaturedMarket({ totalItems: number; }) { const trendingIndex = useStore((s) => s.trendingIndex); + const trendingDirection = useStore((s) => s.trendingDirection); const { data: rawPriceHistory } = usePriceHistory(market.marketId); const priceHistory = rawPriceHistory && rawPriceHistory.length > 0 @@ -138,6 +139,7 @@ export default function FeaturedMarket({ const handlePrev = useCallback(() => { useStore.setState({ trendingIndex: (trendingIndex - 1 + totalItems) % totalItems, + trendingDirection: "prev", trendingAutoAdvancePausedUntil: Date.now() + MANUAL_ADVANCE_PAUSE_MS, }); }, [trendingIndex, totalItems]); @@ -145,6 +147,7 @@ export default function FeaturedMarket({ const handleNext = useCallback(() => { useStore.setState({ trendingIndex: (trendingIndex + 1) % totalItems, + trendingDirection: "next", trendingAutoAdvancePausedUntil: Date.now() + MANUAL_ADVANCE_PAUSE_MS, }); }, [trendingIndex, totalItems]); @@ -198,7 +201,7 @@ export default function FeaturedMarket({ place so the nav arrows never jump. */}