Skip to content

Commit

Permalink
[macOS] Fix rotation (#3122)
Browse files Browse the repository at this point in the history
## Description

Turns out that rotation on macOS works in opposite direction comparing to other platforms. This PR fixes that behavior.

## Test plan

<details>
<summary>Tested on the following code (check `rotation` value in event)</summary>

```tsx
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

export default function EmptyExample() {
  const g = Gesture.Rotation().onChange(console.log);
  return (
    <View style={styles.container}>
      <GestureDetector gesture={g}>
        <View style={{ width: 300, height: 300, backgroundColor: 'red' }} />
      </GestureDetector>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
});
```

</details>
  • Loading branch information
m-bert authored Sep 24, 2024
1 parent 5b41fb1 commit 214663f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apple/Handlers/RNRotationHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ - (instancetype)initWithTag:(NSNumber *)tag
#if TARGET_OS_OSX
- (RNGestureHandlerEventExtraData *)eventExtraData:(NSRotationGestureRecognizer *)recognizer
{
return [RNGestureHandlerEventExtraData forRotation:recognizer.rotation
return [RNGestureHandlerEventExtraData forRotation:-recognizer.rotation
withAnchorPoint:[recognizer locationInView:recognizer.view]
withVelocity:((RNBetterRotationRecognizer *)recognizer).velocity
withNumberOfTouches:2
Expand Down

0 comments on commit 214663f

Please sign in to comment.