admin管理员组文章数量:1431426
I've been looking for a way to disable edge-swipe open of a Drawer. When using horizontal lists, it's accidentally open the Drawer instead of scrolling the list across.
Please check my bellow code:
<Drawer.Navigator
screenOptions={{
swipeEdgeWidth: 0,
}}
drawerContent={(props) => <Menu props={props} />}>
<Drawer.Screen
name="screenWithDrawer1"
options={{
swipeEnabled: false,
unmountOnBlur: true,
headerShown: true,
drawerItemStyle: { display: "none" },
drawerIcon: ({ color }) => (
<FontAwesome5 name="calculator" size={20} color={color} />
),
drawerLabel: 'Purchase Menu',
drawerLabelStyle: { fontSize: 16, paddingLeft: 6 },
title: "Purchase Menu",
headerTitleAlign: 'center',
headerStyle: { backgroundColor: '#f5a756' }
}}
>
{() => (
<Stack.Navigator initialRouteName='purchasemenu'
>
<Stack.Screen
name='purchasemenu'
component={Purchasemenu}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseOrdersList'
component={PurchaseOrdersList}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseWareHouse'
component={PurchaseWareHouse}
options={{ header: () => null }}
/>
<Stack.Screen
name='settings'
component={Settings}
options={{ header: () => null }}
/>
</Stack.Navigator>
)}
</Drawer.Screen>
</Drawer.Navigator>
I have set
swipeEnabled: false
but it's not working.
If anyone can help me I will be grateful.
I've been looking for a way to disable edge-swipe open of a Drawer. When using horizontal lists, it's accidentally open the Drawer instead of scrolling the list across.
Please check my bellow code:
<Drawer.Navigator
screenOptions={{
swipeEdgeWidth: 0,
}}
drawerContent={(props) => <Menu props={props} />}>
<Drawer.Screen
name="screenWithDrawer1"
options={{
swipeEnabled: false,
unmountOnBlur: true,
headerShown: true,
drawerItemStyle: { display: "none" },
drawerIcon: ({ color }) => (
<FontAwesome5 name="calculator" size={20} color={color} />
),
drawerLabel: 'Purchase Menu',
drawerLabelStyle: { fontSize: 16, paddingLeft: 6 },
title: "Purchase Menu",
headerTitleAlign: 'center',
headerStyle: { backgroundColor: '#f5a756' }
}}
>
{() => (
<Stack.Navigator initialRouteName='purchasemenu'
>
<Stack.Screen
name='purchasemenu'
component={Purchasemenu}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseOrdersList'
component={PurchaseOrdersList}
options={{ header: () => null }}
/>
<Stack.Screen
name='purchaseWareHouse'
component={PurchaseWareHouse}
options={{ header: () => null }}
/>
<Stack.Screen
name='settings'
component={Settings}
options={{ header: () => null }}
/>
</Stack.Navigator>
)}
</Drawer.Screen>
</Drawer.Navigator>
I have set
swipeEnabled: false
but it's not working.
If anyone can help me I will be grateful.
Share Improve this question asked Nov 19, 2024 at 8:35 user28353622user283536222 Answers
Reset to default 0There are multiple ways you can resolve this issue
- disable swipe & gestures for the screen with the horizontal carousel
<Drawer.Screen name="screenWithDrawer1"
options={{
swipeEnabled: false, // Disable swipe for this screen
gestureEnabled: false, // disable gestures for this screen
// Other options... }} >
{/* Screen Content */}
</Drawer.Screen>
- Increase your swipe edge & see if this takes effect
<Drawer.Navigator
screenOptions={{ swipeEdgeWidth: 1, // Minimum swipe edge width }}
drawerContent={(props) =>
<Menu props={props} />
}> {/* Other configurations */}
</Drawer.Navigator>
Please try with bellow code
useEffect(() => {
const onBackPress = () => {
return true;
};
const backHandler = BackHandler.addEventListener(
'hardwareBackPress',
onBackPress
);
return () => backHandler.remove();
}, []);
本文标签: react nativeNeed to disable edgeswipe open of a DrawerStack Overflow
版权声明:本文标题:react native - Need to disable edge-swipe open of a Drawer - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745574113a2664223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论