Skip to content

Commit

Permalink
fix: sheet not open on web
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Aug 28, 2022
1 parent 758c5bf commit 3ba0263
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/src/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions dist/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default forwardRef(function ActionSheet(_a, ref) {
var keyboardWasVisible = useRef(false);
var prevKeyboardHeight = useRef(0);
var lock = useRef(false);
var panViewRef = useRef();
var gestureBoundaries = useRef({});
var _8 = useState({
width: Dimensions.get('window').width,
Expand Down Expand Up @@ -225,7 +226,7 @@ export default forwardRef(function ActionSheet(_a, ref) {
portrait: height > width
});
});
if (safeAreaPaddingTop.current !== 0 || Platform.OS === 'android') {
if (safeAreaPaddingTop.current !== 0 || Platform.OS !== 'ios') {
actionSheetEventManager.publish('safeAreaLayout');
}
}, [dimensions.width, isModal, keyboard.keyboardShown]);
Expand Down Expand Up @@ -367,6 +368,16 @@ export default forwardRef(function ActionSheet(_a, ref) {
break;
}
}
if (Platform.OS === 'web') {
if (!gestures) {
//@ts-ignore
panViewRef.current.style.touchAction = 'none';
}
else {
//@ts-ignore
panViewRef.current.style.touchAction = 'auto';
}
}
return gestures;
},
onStartShouldSetPanResponder: function (event, _gesture) {
Expand Down Expand Up @@ -669,7 +680,7 @@ export default forwardRef(function ActionSheet(_a, ref) {
translateY: animations.translateY
},
] })}>
{dimensions.height === 0 ? null : (<Animated.View {...handlers.panHandlers} onLayout={onSheetLayout} testID={(_k = props.testIDs) === null || _k === void 0 ? void 0 : _k.sheet} style={[
{dimensions.height === 0 ? null : (<Animated.View {...handlers.panHandlers} onLayout={onSheetLayout} ref={panViewRef} testID={(_k = props.testIDs) === null || _k === void 0 ? void 0 : _k.sheet} style={[
styles.container,
{
borderTopRightRadius: 10,
Expand Down
14 changes: 13 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
const keyboardWasVisible = useRef(false);
const prevKeyboardHeight = useRef(0);
const lock = useRef(false);
const panViewRef = useRef<View>();
const gestureBoundaries = useRef<{
[name: string]: LayoutRectangle & {
scrollOffset?: number;
Expand Down Expand Up @@ -346,7 +347,7 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
},
);

if (safeAreaPaddingTop.current !== 0 || Platform.OS === 'android') {
if (safeAreaPaddingTop.current !== 0 || Platform.OS !== 'ios') {
actionSheetEventManager.publish('safeAreaLayout');
}
},
Expand Down Expand Up @@ -508,6 +509,15 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
break;
}
}
if (Platform.OS === 'web') {
if (!gestures) {
//@ts-ignore
panViewRef.current.style.touchAction = 'none';
} else {
//@ts-ignore
panViewRef.current.style.touchAction = 'auto';
}
}
return gestures;
},
onStartShouldSetPanResponder: (event, _gesture) => {
Expand All @@ -532,6 +542,7 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
gestures = false;
}
}

return gestures;
}
return true;
Expand Down Expand Up @@ -902,6 +913,7 @@ export default forwardRef<ActionSheetRef, ActionSheetProps>(
<Animated.View
{...handlers.panHandlers}
onLayout={onSheetLayout}
ref={panViewRef}
testID={props.testIDs?.sheet}
style={[
styles.container,
Expand Down

1 comment on commit 3ba0263

@vercel
Copy link

@vercel vercel bot commented on 3ba0263 Aug 28, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

rnas – ./

rnas-ammarahm-ed.vercel.app
rnas.vercel.app
rnas-git-master-ammarahm-ed.vercel.app

Please sign in to comment.