Skip to content

Commit c0f3e57

Browse files
committed
simplify
1 parent 355edf9 commit c0f3e57

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-draggable-flatlist",
3-
"version": "4.0.0-beta.7",
3+
"version": "4.0.0-beta.8",
44
"description": "A drag-and-drop-enabled FlatList component for React Native",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/components/DraggableFlatList.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,26 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
171171
const onDragEnd = useStableCallback(
172172
({ from, to }: { from: number; to: number }) => {
173173
const { onDragEnd, data } = props;
174-
if (onDragEnd) {
175-
const newData = [...data];
176-
if (from !== to) {
177-
newData.splice(from, 1);
178-
newData.splice(to, 0, data[from]);
179-
}
180-
const reset = () => {
181-
activeIndexAnim.value = -1;
182-
spacerIndexAnim.value = -1;
183-
touchTranslate.value = 0;
184-
activeCellSize.value = -1;
185-
activeCellOffset.value = -1;
186-
setActiveKey(null);
187-
};
188-
189-
if (isWeb) reset();
190-
else setTimeout(reset);
191-
192-
onDragEnd({ from, to, data: newData });
174+
175+
const newData = [...data];
176+
if (from !== to) {
177+
newData.splice(from, 1);
178+
newData.splice(to, 0, data[from]);
193179
}
180+
181+
const reset = () => {
182+
activeIndexAnim.value = -1;
183+
spacerIndexAnim.value = -1;
184+
touchTranslate.value = 0;
185+
activeCellSize.value = -1;
186+
activeCellOffset.value = -1;
187+
setActiveKey(null);
188+
};
189+
190+
if (isWeb) reset();
191+
else setTimeout(reset);
192+
193+
onDragEnd?.({ from, to, data: newData });
194194
}
195195
);
196196

0 commit comments

Comments
 (0)