Skip to content

Commit cf0be59

Browse files
committed
feat: add threshold props made by @adrianso
1 parent 1ebdab5 commit cf0be59

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

docs/PROPSMETHODS.md

+8
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ A number that determines the momentum of the scroll required.
124124
| -------- | -------- | ------- |
125125
| number | No | `0.05` |
126126

127+
### `threshold`
128+
129+
Number of pixels that the user must drag the modal before snapping to another position.
130+
131+
| Type | Required | Default |
132+
| -------- | -------- | ------- |
133+
| number | No | `150` |
134+
127135
### `adjustToContentHeight`
128136

129137
Shrink the modal to your content's height.

src/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const AnimatedKeyboardAvoidingView = Animated.createAnimatedComponent(KeyboardAv
3838
const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
3939
const AnimatedSectionList = Animated.createAnimatedComponent(SectionList);
4040
const GestureHandlerWrapper = GestureHandlerRootView ?? View;
41-
const THRESHOLD = 150;
4241
const ACTIVATED = 20;
4342
const PAN_DURATION = 150;
4443

@@ -73,6 +72,7 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
7372
timing: { duration: 280, easing: Easing.ease },
7473
},
7574
dragToss: 0.05,
75+
threshold: 150,
7676
};
7777

7878
private snaps: number[] = [];
@@ -460,6 +460,7 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
460460
dragToss,
461461
onPositionChange,
462462
panGestureAnimatedValue,
463+
threshold,
463464
} = this.props;
464465
const { timing } = closeAnimationConfig!;
465466
const { lastSnap, modalHeight, overlay } = this.state;
@@ -492,7 +493,7 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
492493
}
493494
});
494495
} else if (
495-
translationY > (adjustToContentHeight ? (modalHeight || 0) / 3 : THRESHOLD) &&
496+
translationY > (adjustToContentHeight ? (modalHeight || 0) / 3 : threshold) &&
496497
this.beginScrollYValue === 0 &&
497498
!alwaysOpen
498499
) {

src/options.ts

+6
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ export interface IProps<FlatListItem = any, SectionListItem = any> {
122122
*/
123123
dragToss: number;
124124

125+
/**
126+
* Number of pixels that the user must drag the modal before snapping to another position.
127+
* @default 150
128+
*/
129+
threshold: number;
130+
125131
/**
126132
* Shrink the modal to your content's height.
127133
* @default false

0 commit comments

Comments
 (0)