fix: correct RTL project drag direction
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user