Skip to content

Commit abf9105

Browse files
committed
fix web flicker
1 parent d246cb8 commit abf9105

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/DraggableFlatList.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Animated, {
1313
withSpring,
1414
} from "react-native-reanimated";
1515
import CellRendererComponent from "./CellRendererComponent";
16-
import { DEFAULT_PROPS } from "../constants";
16+
import { DEFAULT_PROPS, isWeb } from "../constants";
1717
import PlaceholderItem from "./PlaceholderItem";
1818
import RowItem from "./RowItem";
1919
import { DraggableFlatListProps } from "../types";
@@ -170,14 +170,18 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
170170
newData.splice(from, 1);
171171
newData.splice(to, 0, data[from]);
172172
}
173-
setTimeout(() => {
173+
const reset = () => {
174174
activeIndexAnim.value = -1;
175175
spacerIndexAnim.value = -1;
176176
touchTranslate.value = 0;
177177
activeCellSize.value = -1;
178178
activeCellOffset.value = -1;
179179
setActiveKey(null);
180-
});
180+
};
181+
182+
if (isWeb) reset();
183+
else setTimeout(reset);
184+
181185
onDragEnd({ from, to, data: newData });
182186
}
183187
}

0 commit comments

Comments
 (0)