Skip to content

Commit 7f52243

Browse files
author
Luke Brandon Farrell
authored
Merge pull request #63 from CursedWizard/master
feat(swipe): added option to disable dragging/swiping gestures.
2 parents d1cc7fb + cc06d32 commit 7f52243

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ props will be passed to your custom drawer component.
101101
| fadeOpacity | number | Yes | 0.6 | Opacity of the screen outside the drawer. |
102102
| drawerScreenWidth | number | Yes | 0.8 | 0 - 1, width of drawer in relation to the screen. |
103103
| drawerScreenHeight | number | Yes | 1 | 0 - 1, height of drawer in relation to the screen. |
104+
| disableDragging | boolean | Yes | false | Whether you want to disable dragging of the drawer. Useful if you have ScrollView inside the drawer (addresses #62).|
105+
| disableSwiping | boolean | Yes | false | Whether you want to disable swiping gesture. Use it only in pair with disableDragging.|
104106

105107
## SideMenuView
106108

src/RNNDrawer.tsx

+15-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ declare interface RNNDrawerOptions {
6969
* Height of drawer in relation to the screen (0 to 1)
7070
*/
7171
drawerScreenHeight?: number;
72+
73+
disableDragging?: boolean;
74+
75+
disableSwiping?: boolean;
7276
}
7377

7478
export enum DirectionType {
@@ -103,6 +107,8 @@ interface IProps {
103107
drawerScreenWidth: number | string;
104108
drawerScreenHeight: number | string;
105109
animateDrawerExpanding?: boolean;
110+
disableDragging?: boolean;
111+
disableSwiping?: boolean;
106112
style: any;
107113
}
108114

@@ -167,7 +173,9 @@ class RNNDrawer {
167173
fadeOpacity: 0.6,
168174
drawerScreenWidth: '80%',
169175
drawerScreenHeight: '100%',
170-
animateDrawerExpanding: true
176+
animateDrawerExpanding: true,
177+
disableDragging: false,
178+
disableSwiping: false
171179
};
172180

173181
/**
@@ -434,6 +442,8 @@ class RNNDrawer {
434442
return;
435443
}
436444

445+
if (this.props.disableDragging)
446+
return;
437447
// Calculates the translateX / translateY value
438448
let alignedMovementValue = 0;
439449
// To swap the direction if needed
@@ -476,6 +486,9 @@ class RNNDrawer {
476486
this.unsubscribeSwipeEnd = listen(
477487
'SWIPE_END',
478488
(swipeDirection: string) => {
489+
if (this.props.disableSwiping && !this.startedFromSideMenu)
490+
return;
491+
479492
const reverseDirection: DrawerReverseDirectionInterface = {
480493
right: 'left',
481494
left: 'right',
@@ -667,3 +680,4 @@ const styles = StyleSheet.create<StylesInterface>({
667680
backgroundColor: '#000',
668681
},
669682
});
683+

0 commit comments

Comments
 (0)