Skip to content

Commit a04a6ba

Browse files
committed
move prevTranslate set to onChange in runCode
1 parent 16ce38c commit a04a6ba

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,7 @@ class SwipeableItem<T> extends React.PureComponent<Props<T>> {
227227
onHandlerStateChange = event([
228228
{
229229
nativeEvent: ({ state }: GestureHandlerStateChangeNativeEvent) =>
230-
block([
231-
set(this.gestureState, state),
232-
cond(
233-
eq(this.gestureState, GestureState.BEGAN),
234-
set(this.prevTranslate, this.animState.position)
235-
)
236-
])
230+
set(this.gestureState, state)
237231
}
238232
]);
239233

@@ -308,6 +302,13 @@ class SwipeableItem<T> extends React.PureComponent<Props<T>> {
308302
startClock(this.clock)
309303
])
310304
]),
305+
onChange(
306+
this.gestureState,
307+
cond(eq(this.gestureState, GestureState.BEGAN), [
308+
cond(clockRunning(this.clock), stopClock(this.clock)),
309+
set(this.prevTranslate, this.animState.position)
310+
])
311+
),
311312
onChange(this.isSwiping, call([this.isSwiping], this.onIsSwipingChange)),
312313
// If the clock is running, increment position in next tick by calling spring()
313314
cond(clockRunning(this.clock), [

0 commit comments

Comments
 (0)