fix: correct RTL project drag direction
Some checks failed
Test and deploy / Verify production build (push) Has been cancelled
Test and deploy / Deploy production (push) Has been cancelled

This commit is contained in:
2026-09-08 23:09:23 +03:30
parent b682d2de32
commit 9143ba8504

View File

@@ -158,9 +158,10 @@ export const ProjectsSection = ({ locale }: { locale: Locale }) => {
dragState.current.lastTime = now; dragState.current.lastTime = now;
if (Math.abs(deltaX) > 4) dragState.current.moved = true; if (Math.abs(deltaX) > 4) dragState.current.moved = true;
const dragDirection = isRtl ? 1 : -1;
setLogicalScrollLeft( setLogicalScrollLeft(
viewport, viewport,
dragState.current.startLogicalScrollLeft - deltaX, dragState.current.startLogicalScrollLeft + deltaX * dragDirection,
isRtl, isRtl,
); );
} }
@@ -205,7 +206,11 @@ export const ProjectsSection = ({ locale }: { locale: Locale }) => {
const currentScroll = getLogicalScrollLeft(viewport, isRtl); const currentScroll = getLogicalScrollLeft(viewport, isRtl);
let targetIndex: number; let targetIndex: number;
if (Math.abs(velocity) > 0.2 || Math.abs(totalDeltaX) > cardWidth * 0.18) { 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); targetIndex = Math.ceil(currentScroll / step);
} else { } else {
targetIndex = Math.floor(currentScroll / step); targetIndex = Math.floor(currentScroll / step);