Skip to content

Commit

Permalink
fix: Invalid fromIndex in onDragEnd callback (#284)
Browse files Browse the repository at this point in the history
## Description

I cleared `dragStartIndex` (passed as `fromIndex` to the `onDragEnd`
callback) before the callback was called, hence the user always received
`-1` instead of the actual drag start index.
  • Loading branch information
MatiPl01 authored Feb 26, 2025
1 parent d4ecfb8 commit 8ac4ea3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
const handleDragEnd = useCallback(
(key: string, activationAnimationProgress: SharedValue<number>) => {
'worklet';
dragStartIndex.value = -1;
touchStartTouch.value = null;
dragStartTouch.value = null;
dragStartItemTouchOffset.value = null;
Expand Down Expand Up @@ -443,6 +442,7 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
const animate = (callback?: (finished: boolean | undefined) => void) =>
withTiming(0, { duration: dropAnimationDuration.value }, callback);

dragStartIndex.value = -1;
activationAnimationProgress.value = animate();
inactiveAnimationProgress.value = animate();

Expand Down

0 comments on commit 8ac4ea3

Please sign in to comment.