Skip to content

Commit 7f2128e

Browse files
committed
remove unnecessary hasMoved state, fix case where tap on same item without moving
1 parent 503d19b commit 7f2128e

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

src/components/DraggableFlatList.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
7878
activeIndexAnim,
7979
containerSize,
8080
disabled,
81-
hasMoved,
8281
panGestureState,
8382
resetTouchedCell,
8483
scrollOffset,
@@ -245,7 +244,6 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
245244
set(disabled, 1),
246245
set(isTouchActiveRef.current.native, 0),
247246
call([activeIndexAnim], onRelease),
248-
cond(not(hasMoved), call([activeIndexAnim], resetHoverState)),
249247
],
250248
[call([activeIndexAnim], resetHoverState), resetTouchedCell]
251249
)
@@ -323,17 +321,13 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
323321
eq(panGestureState, GestureState.ACTIVE),
324322
not(disabled)
325323
),
326-
[
327-
cond(not(hasMoved), set(hasMoved, 1)),
328-
set(touchAbsolute, props.horizontal ? x : y),
329-
]
324+
[set(touchAbsolute, props.horizontal ? x : y)]
330325
),
331326
},
332327
]),
333328
[
334329
activeIndexAnim,
335330
disabled,
336-
hasMoved,
337331
panGestureState,
338332
props.horizontal,
339333
touchAbsolute,

src/context/animatedValueContext.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function useSetupAnimatedValues<T>() {
5757

5858
const isTouchActiveNative = useValue<number>(0);
5959

60-
const hasMoved = useValue<number>(0);
6160
const disabled = useValue<number>(0);
6261

6362
const horizontalAnim = useValue(props.horizontal ? 1 : 0);
@@ -102,7 +101,6 @@ function useSetupAnimatedValues<T>() {
102101
set(touchInit, 0),
103102
set(activeCellOffset, 0),
104103
set(activationDistance, 0),
105-
set(hasMoved, 0),
106104
])
107105
);
108106

@@ -114,7 +112,6 @@ function useSetupAnimatedValues<T>() {
114112
activeIndexAnim,
115113
containerSize,
116114
disabled,
117-
hasMoved,
118115
horizontalAnim,
119116
hoverAnim,
120117
hoverAnimConstrained,
@@ -140,7 +137,6 @@ function useSetupAnimatedValues<T>() {
140137
activeIndexAnim,
141138
containerSize,
142139
disabled,
143-
hasMoved,
144140
horizontalAnim,
145141
hoverAnim,
146142
hoverAnimConstrained,

src/hooks/useCellTranslate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function useCellTranslate({ cellIndex, cellSize, cellOffset }: Params) {
9191
)
9292
);
9393

94-
// This is required to continually evaluate values
94+
// This is a workaround required to continually evaluate values
9595
useCode(
9696
() =>
9797
block([

0 commit comments

Comments
 (0)