Skip to content

Commit 8000025

Browse files
committed
perf tweaks
1 parent fdf00f3 commit 8000025

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

src/components/CellRendererComponent.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,11 @@ function CellRendererComponent<T>(props: Props<T>) {
142142
isAndroid && { elevation: isActive ? 1 : 0 },
143143
{ flexDirection: horizontal ? "row" : "column" },
144144
(isWeb || isIOS) && { zIndex: isActive ? 999 : 0 },
145+
style,
145146
]}
146147
pointerEvents={activeKey ? "none" : "auto"}
147148
>
148-
<Animated.View
149-
// Including both animated styles and non-animated styles causes react-native-web
150-
// to ignore updates in non-animated styles. Solution is to separate anima
151-
style={style}
152-
>
153-
<CellProvider isActive={isActive}>{children}</CellProvider>
154-
</Animated.View>
149+
<CellProvider isActive={isActive}>{children}</CellProvider>
155150
</Animated.View>
156151
);
157152
}

src/components/DraggableFlatList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function DraggableFlatListInner<T>(props: DraggableFlatListProps<T>) {
402402
extraData={extraData}
403403
keyExtractor={keyExtractor}
404404
onScroll={scrollHandler}
405-
scrollEventThrottle={1}
405+
scrollEventThrottle={16}
406406
simultaneousHandlers={props.simultaneousHandlers}
407407
removeClippedSubviews={false}
408408
/>

src/procs.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,26 @@ export const setupCell = proc(
203203
set(finished, 0),
204204
startClock(clock),
205205
]),
206+
207+
cond(neq(prevSpacerIndex, spacerIndex), [
208+
cond(eq(spacerIndex, -1), [
209+
// Hard reset to prevent stale state bugs
210+
cond(clockRunning(clock), stopClock(clock)),
211+
hardReset(position, finished, time, toValue),
212+
]),
213+
]),
214+
cond(finished, [onFinished, set(time, 0), set(finished, 0)]),
215+
set(prevSpacerIndex, spacerIndex),
216+
set(prevToValue, toValue),
217+
set(prevIsDraggingCell, isDraggingCell),
218+
cond(clockRunning(clock), runSpring),
206219
],
207220
[
208-
// Reset the spacer index when drag ends
209-
set(spacerIndex, -1),
210-
set(position, 0),
221+
// // Reset the spacer index when drag ends
222+
cond(neq(spacerIndex, -1), set(spacerIndex, -1)),
223+
cond(neq(position, 0), set(position, 0)),
211224
]
212225
),
213-
cond(neq(prevSpacerIndex, spacerIndex), [
214-
cond(eq(spacerIndex, -1), [
215-
// Hard reset to prevent stale state bugs
216-
cond(clockRunning(clock), stopClock(clock)),
217-
hardReset(position, finished, time, toValue),
218-
]),
219-
]),
220-
cond(finished, [onFinished, set(time, 0), set(finished, 0)]),
221-
set(prevSpacerIndex, spacerIndex),
222-
set(prevToValue, toValue),
223-
set(prevIsDraggingCell, isDraggingCell),
224-
cond(clockRunning(clock), runSpring),
225226
position,
226227
])
227228
);

0 commit comments

Comments
 (0)