From 9143ba8504d62dfe523779b34470f1122a3fe466 Mon Sep 17 00:00:00 2001 From: Amirhossein Khalili Date: Tue, 8 Sep 2026 23:09:23 +0330 Subject: [PATCH] fix: correct RTL project drag direction --- src/components/ProjectsSection.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/ProjectsSection.tsx b/src/components/ProjectsSection.tsx index 8ba8d0d..0feb937 100644 --- a/src/components/ProjectsSection.tsx +++ b/src/components/ProjectsSection.tsx @@ -158,9 +158,10 @@ export const ProjectsSection = ({ locale }: { locale: Locale }) => { dragState.current.lastTime = now; if (Math.abs(deltaX) > 4) dragState.current.moved = true; + const dragDirection = isRtl ? 1 : -1; setLogicalScrollLeft( viewport, - dragState.current.startLogicalScrollLeft - deltaX, + dragState.current.startLogicalScrollLeft + deltaX * dragDirection, isRtl, ); } @@ -205,7 +206,11 @@ export const ProjectsSection = ({ locale }: { locale: Locale }) => { const currentScroll = getLogicalScrollLeft(viewport, isRtl); let targetIndex: number; if (Math.abs(velocity) > 0.2 || Math.abs(totalDeltaX) > cardWidth * 0.18) { - if (totalDeltaX < 0 || velocity < -0.2) { + const isForwardGesture = isRtl + ? totalDeltaX > 0 || velocity > 0.2 + : totalDeltaX < 0 || velocity < -0.2; + + if (isForwardGesture) { targetIndex = Math.ceil(currentScroll / step); } else { targetIndex = Math.floor(currentScroll / step);