Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Android RotationGestureHandler state transitions so onFinalize receives the correct success flag when rotation never activates but pointers are released (aligning behavior with the intended gesture lifecycle).
Changes:
- Update
onRotationEndtoend()only when the handler isSTATE_ACTIVE, otherwisefail(). - Remove dead
ACTION_UPhandling fromonHandleand keep a targeted fail path for single-pointerACTION_UPwhile still inSTATE_BEGAN.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rotation handlerRotation handler
j-piasecki
approved these changes
Apr 13, 2026
m-bert
added a commit
that referenced
this pull request
Apr 13, 2026
## Description I've noticed that `Pinch` and `Rotation` behave weirdly when it comes to ending gesture on web. I've took a look and fixed some minor issues. > [!NOTE] > This PR may introduce mismatch between `android` and `web` versions of `Rotation`. I still think that this is how it is supposed to work, so we may want to [make required changes to `android` as well](#4079) (or drop this PR if you prefer to). ### Pinch I've noticed that `Pinch` is not reset when pointers are placed on view and then released. This was because for some reason `Pinch` simply ignored finished states if it had not activated earlier. ### Rotation `Rotation`, always finalized with `true`. This was because we always tried to move it to `end` state. Our internal event handler hadn't been sending `onDeactivate`, but `true` was still passed into `onFinalize`. ## Test plan <details> <summary>Tested on Transformations example and code below:</summary> ```tsx import { StyleSheet, View } from 'react-native'; import { GestureDetector, GestureHandlerRootView, usePinchGesture, useRotationGesture, } from 'react-native-gesture-handler'; export default function App() { const g = useRotationGesture({ onBegin: () => console.log('onBegin'), onActivate: () => console.log('onActivate'), onUpdate: (e) => console.log('onUpdate', e.rotation), onDeactivate: () => console.log('onDeactivate'), onFinalize: (_, s) => console.log('onFinalize', s), }); return ( <GestureHandlerRootView style={styles.container}> <GestureDetector gesture={g}> <View style={styles.box} /> </GestureDetector> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', }, box: { width: 200, height: 200, backgroundColor: 'blue', borderRadius: 12, }, }); ``` </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow up for #4078
I've noticed that when
Rotationdoes not activate, but pointers are released,onFinalizeis called withtrue. This happens because we try to move it toENDstate, but our internal logic does not sendonDeactivate.Code in
onHandlethat I removed was effectively dead, asACTION_UPwas handled in rotation detector - the only possible branch waselsestatement which fails handler if only one pointer was present.Test plan
Tested on Transformations example and the following code: