Skip to content

Commit 5a16682

Browse files
committed
add callback to pass the touch event up
1 parent 93cf9fc commit 5a16682

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
BackHandler,
1414
Dimensions,
1515
Easing,
16+
GestureResponderEvent,
1617
LayoutChangeEvent,
1718
LayoutRectangle,
1819
Modal,
@@ -101,6 +102,7 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
101102
overlayColor = 'black',
102103
closable = true,
103104
closeOnTouchBackdrop = true,
105+
onTouchBackdrop,
104106
drawUnderStatusBar = false,
105107
gestureEnabled = false,
106108
isModal = true,
@@ -702,7 +704,8 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
702704
],
703705
);
704706

705-
const onTouch = () => {
707+
const onTouch = (event: GestureResponderEvent) => {
708+
onTouchBackdrop?.(event);
706709
if (enableRouterBackNavigation && router.canGoBack()) {
707710
router.goBack();
708711
return;

src/types.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import {Route} from './hooks/use-router';
22
import React from 'react';
3-
import {Animated, TouchableOpacityProps, ViewStyle} from 'react-native';
3+
import {
4+
Animated,
5+
GestureResponderEvent,
6+
TouchableOpacityProps,
7+
ViewStyle,
8+
} from 'react-native';
49

510
export type ActionSheetProps = {
611
children?: React.ReactNode;
@@ -133,6 +138,13 @@ export type ActionSheetProps = {
133138
*/
134139
closeOnTouchBackdrop?: boolean;
135140

141+
/**
142+
* Callback when user touches the backdrop. Includes the GestureResponderEvent.
143+
*
144+
* Default: undefined
145+
*/
146+
onTouchBackdrop?: (event: GestureResponderEvent) => void;
147+
136148
/**
137149
* Render a component over the ActionSheet. Useful for rendering
138150
* Toast components with which user can interact. Should be `absolutely` positioned.

0 commit comments

Comments
 (0)