diff --git a/example/src/App.tsx b/example/src/App.tsx
index 1cc7748..5a609d1 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -5,6 +5,7 @@ import {DraggableStackExample as DraggableExample} from './pages/DraggableStackE
import {DraggableBasicExample} from './pages/DraggableBasicExample';
import {SafeAreaView, StyleSheet} from 'react-native';
import {configureReanimatedLogger} from 'react-native-reanimated';
+import HomeScreen from './pages/OtherExample';
// This is the default configuration
configureReanimatedLogger({
@@ -18,7 +19,7 @@ export const App: FunctionComponent = () => {
{/* */}
{/* */}
-
+
);
diff --git a/package.json b/package.json
index ae9d7b4..ebc4540 100644
--- a/package.json
+++ b/package.json
@@ -60,5 +60,6 @@
"tsc-alias": "^1.8.10",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
- }
+ },
+ "packageManager": "pnpm@9.15.0+sha512.76e2379760a4328ec4415815bcd6628dee727af3779aaa4c914e3944156c4299921a89f976381ee107d41f12cfa4b66681ca9c718f0668fa0831ed4c6d8ba56c"
}
diff --git a/src/features/sort/components/DraggableStack.tsx b/src/features/sort/components/DraggableStack.tsx
index fa32ca0..3764f1d 100644
--- a/src/features/sort/components/DraggableStack.tsx
+++ b/src/features/sort/components/DraggableStack.tsx
@@ -41,7 +41,7 @@ export const DraggableStack = forwardRef {
return {
refreshOffsets,
+ resetSortOrder,
};
- }, [refreshOffsets]);
+ }, [refreshOffsets, resetSortOrder]);
useEffect(() => {
// Refresh offsets when children change
diff --git a/src/features/sort/hooks/useDraggableStack.ts b/src/features/sort/hooks/useDraggableStack.ts
index e6a51df..7b75f47 100644
--- a/src/features/sort/hooks/useDraggableStack.ts
+++ b/src/features/sort/hooks/useDraggableStack.ts
@@ -113,6 +113,13 @@ export const useDraggableStack = ({
horizontal,
]);
+ const resetSortOrder = useCallback(() => {
+ // Reset the expected sort order
+ draggableSortOrder.value = childrenIds.slice();
+ // Refresh all offsets
+ refreshOffsets();
+ }, [childrenIds, draggableSortOrder, refreshOffsets]);
+
// Track items being added or removed from the stack
useAnimatedReaction(
() => childrenIds,
@@ -125,7 +132,7 @@ export const useDraggableStack = ({
return;
}
// Reset the expected sort order
- draggableSortOrder.value = next;
+ // draggableSortOrder.value = next;
// Refresh all offsets
refreshOffsets();
},
@@ -189,5 +196,5 @@ export const useDraggableStack = ({
[horizontal],
);
- return { draggablePlaceholderIndex, draggableSortOrder, refreshOffsets };
+ return { draggablePlaceholderIndex, draggableSortOrder, resetSortOrder, refreshOffsets };
};