Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ PODS:
- React-jsi (= 0.72.7)
- React-logger (= 0.72.7)
- React-perflogger (= 0.72.7)
- rive-react-native (6.1.1):
- rive-react-native (6.2.0):
- React-Core
- RiveRuntime (= 5.5.1)
- RiveRuntime (5.5.1)
Expand Down Expand Up @@ -744,7 +744,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: 7649c3b46c8dee1853691ecf60146a16ae59253c
React-utils: 56838edeaaf651220d1e53cd0b8934fb8ce68415
ReactCommon: 5f704096ccf7733b390f59043b6fa9cc180ee4f6
rive-react-native: 112e318d564488e79cef71ed192f13b5768e196b
rive-react-native: 82eb809ebec7ab5059982dc1a2b6097c74d722ea
RiveRuntime: b57830ff73f406f3b4022f457b16690535ca4d05
RNCMaskedView: 949696f25ec596bfc697fc88e6f95cf0c79669b6
RNCPicker: 0991c56da7815c0cf946d6f63cf920b25296e5f6
Expand Down
9 changes: 9 additions & 0 deletions src/Rive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type RiveProps = {
message: string;
}>
) => void;
onPress?: () => void;
isUserHandlingErrors: boolean;
autoplay?: boolean;
fit: Fit;
Expand All @@ -78,6 +79,7 @@ type RiveProps = {
url?: string;
style?: StyleProp<ViewStyle>;
testID?: string;
disableDefaultTouchHandling?: boolean;
};

const VIEW_NAME = 'RiveReactNativeView';
Expand All @@ -90,6 +92,7 @@ type Props = {
onStateChanged?: (stateMachineName: string, stateName: string) => void;
onRiveEventReceived?: (event: RiveGeneralEvent | RiveOpenUrlEvent) => void;
onError?: (rnRiveError: RNRiveError) => void;
onPress?: () => void;
fit?: Fit;
style?: ViewStyle;
testID?: string;
Expand All @@ -99,6 +102,7 @@ type Props = {
stateMachineName?: string;
autoplay?: boolean;
children?: React.ReactNode;
disableDefaultTouchHandling?: boolean;
} & XOR<{ resourceName: string }, { url: string }>;

export const RiveViewManager = requireNativeComponent<RiveProps>(VIEW_NAME);
Expand All @@ -114,6 +118,7 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
onStateChanged,
onRiveEventReceived,
onError,
onPress,
style,
autoplay = true,
resourceName,
Expand All @@ -124,6 +129,7 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
animationName,
stateMachineName,
testID,
disableDefaultTouchHandling = false,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reduce this variable and do something like this
const isDisableDefaultTouch = onPress

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can ignore this if we need to support onPressIn at the same time too.

},
ref
) => {
Expand Down Expand Up @@ -364,11 +370,14 @@ const RiveContainer = React.forwardRef<RiveRef, Props>(
<View style={styles.children}>{children}</View>
<TouchableWithoutFeedback
onPressIn={(event: GestureResponderEvent) =>
!disableDefaultTouchHandling &&
touchBegan(event.nativeEvent.locationX, event.nativeEvent.locationY)
}
onPressOut={(event: GestureResponderEvent) =>
!disableDefaultTouchHandling &&
touchEnded(event.nativeEvent.locationX, event.nativeEvent.locationY)
}
onPress={onPress}
>
<RiveViewManager
ref={riveRef}
Expand Down