Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/components/CellRendererComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
LayoutChangeEvent,
MeasureLayoutOnSuccessCallback,
StyleProp,
StyleSheet,
ViewStyle,
} from "react-native";
import Animated, {
Expand Down Expand Up @@ -163,11 +162,7 @@ function CellRendererComponent<T>(props: Props<T>) {
? itemLayoutAnimation
: undefined
}
style={[
props.style,
baseStyle,
activeKey ? animStyle : styles.zeroTranslate,
]}
style={[props.style, baseStyle, animStyle]}
pointerEvents={activeKey ? "none" : "auto"}
>
<CellProvider isActive={isActive}>{children}</CellProvider>
Expand All @@ -177,12 +172,6 @@ function CellRendererComponent<T>(props: Props<T>) {

export default typedMemo(CellRendererComponent);

const styles = StyleSheet.create({
zeroTranslate: {
transform: [{ translateX: 0 }, { translateY: 0 }],
},
});

declare global {
namespace NodeJS {
interface Global {
Expand Down
15 changes: 12 additions & 3 deletions src/components/DraggableFlatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import React, {
useRef,
useState,
} from "react";
import { ListRenderItem, FlatListProps, LayoutChangeEvent } from "react-native";
import {
ListRenderItem,
FlatListProps,
LayoutChangeEvent,
InteractionManager,
} from "react-native";
import {
FlatList,
Gesture,
Expand All @@ -20,7 +25,7 @@ import Animated, {
withSpring,
} from "react-native-reanimated";
import CellRendererComponent from "./CellRendererComponent";
import { DEFAULT_PROPS, isWeb } from "../constants";
import { DEFAULT_PROPS } from "../constants";
import PlaceholderItem from "./PlaceholderItem";
import RowItem from "./RowItem";
import { DraggableFlatListProps } from "../types";
Expand Down Expand Up @@ -114,6 +119,9 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
if (dataHasChanged) {
// When data changes make sure `activeKey` is nulled out in the same render pass
activeKey = null;
InteractionManager.runAfterInteractions(() => {
reset();
});
}

useEffect(() => {
Expand Down Expand Up @@ -221,7 +229,8 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
}

onDragEnd?.({ from, to, data: newData });
reset();

setActiveKey(null);
}
);

Expand Down