Skip to content

Commit 8ca7e40

Browse files
committed
SortableGridList - add RTL support (#2198)
1 parent fdc0ea3 commit 8ca7e40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/sortableGridList/usePresenter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ const usePresenter = (numOfColumns: number, itemSpacing: number) => {
3232
const newColumn = newOrder % numOfColumns;
3333

3434
const translation = {
35-
x: (newColumn - oldColumn) * ((itemLayout.value?.width ?? 0) + itemSpacing),
35+
x: (Constants.isRTL ? -1 : 1) * (newColumn - oldColumn) * ((itemLayout.value?.width ?? 0) + itemSpacing),
3636
y: (newRow - oldRow) * ((itemLayout.value?.height ?? 0) + itemSpacing)
3737
};
3838
return translation;
3939
},
4040
getOrderByPosition: (positionX: number, positionY: number) => {
4141
'worklet';
42-
const col = Math.round(positionX / itemSize);
42+
const col = (Constants.isRTL ? -1 : 1) * Math.round(positionX / itemSize);
4343
const row = Math.round(positionY / itemSize);
4444
return row * numOfColumns + col;
4545
},

0 commit comments

Comments
 (0)