Skip to content

Commit 494d8c5

Browse files
committed
Cancel a gesture after issuing the action
This ensures that we have already scheduled some work before we cancel. That way we know that this work will be the one to commit the new state. Otherwise we might cancel too soon.
1 parent 134a862 commit 494d8c5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fixtures/view-transition/src/components/SwipeRecognizer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ export default function SwipeRecognizer({
3333
});
3434
}
3535
function onScrollEnd() {
36-
if (activeGesture.current !== null) {
37-
const cancelGesture = activeGesture.current;
38-
activeGesture.current = null;
39-
cancelGesture();
40-
}
4136
let changed;
4237
const scrollElement = scrollRef.current;
4338
if (axis === 'x') {
@@ -60,6 +55,11 @@ export default function SwipeRecognizer({
6055
// Trigger side-effects
6156
startTransition(action);
6257
}
58+
if (activeGesture.current !== null) {
59+
const cancelGesture = activeGesture.current;
60+
activeGesture.current = null;
61+
cancelGesture();
62+
}
6363
}
6464

6565
useEffect(() => {

0 commit comments

Comments
 (0)