Skip to content

Commit

Permalink
Merge pull request #73 from lukahc/onShouldBlockNativeResponder
Browse files Browse the repository at this point in the history
onShouldBlockNativeResponder
  • Loading branch information
elliottkember committed Oct 6, 2023
2 parents 2ed7ec2 + ca71d95 commit ad42e6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ Sometimes you need to change deeper level behavior, so we prepared these panresp
| onPanResponderTerminate | Will be called when the gesture is force-interrupted by another handler | event, gestureState, zoomableViewEventObject | void |
| onPanResponderTerminationRequest | Callback asking whether the gesture should be interrupted by another handler (**iOS only** due to https://github.com/facebook/react-native/issues/27778, https://github.com/facebook/react-native/issues/5696, ...) | event, gestureState, zoomableViewEventObject | void |
| onPanResponderMove | Will be called when user moves while touching | event, gestureState, zoomableViewEventObject | void |
| onShouldBlockNativeResponder | Returns whether this component should block native components from becoming the JS responder | event, gestureState, zoomableViewEventObject | boolean |

### zoomableViewEventObject

Expand Down
7 changes: 6 additions & 1 deletion src/ReactNativeZoomableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ class ReactNativeZoomableView extends Component<
gestureState,
this._getZoomableViewEventObject()
),
onShouldBlockNativeResponder: () => false,
onShouldBlockNativeResponder: (evt, gestureState) =>
!!this.props.onShouldBlockNativeResponder?.(
evt,
gestureState,
this._getZoomableViewEventObject()
),
});

this.zoomSubjectWrapperRef = createRef<View>();
Expand Down
5 changes: 5 additions & 0 deletions src/typings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ export interface ReactNativeZoomableViewProps extends ViewProps {
gestureState: PanResponderGestureState,
zoomableViewEventObject: ZoomableViewEvent
) => boolean;
onShouldBlockNativeResponder?: (
event: GestureResponderEvent,
gestureState: PanResponderGestureState,
zoomableViewEventObject: ZoomableViewEvent
) => boolean;
}

export interface Vec2D {
Expand Down

0 comments on commit ad42e6d

Please sign in to comment.