@@ -41,6 +41,11 @@ type Props = {
4141 */
4242 enabledContentTapInteraction ?: boolean
4343
44+ /**
45+ * When true, clamp bottom position to first snapPoint.
46+ */
47+ enabledBottomClamp ?: boolean
48+
4449 /**
4550 * If false blocks snapping using snapTo method. Defaults to true.
4651 */
@@ -286,6 +291,7 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
286291 initialSnap : 0 ,
287292 enabledImperativeSnapping : true ,
288293 enabledGestureInteraction : true ,
294+ enabledBottomClamp : false ,
289295 enabledHeaderGestureInteraction : true ,
290296 enabledContentGestureInteraction : true ,
291297 enabledContentTapInteraction : true ,
@@ -317,6 +323,7 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
317323 private tapRef : React . RefObject < TapGestureHandler >
318324 private snapPoint : Animated . Node < number >
319325 private Y : Animated . Node < number >
326+ private clampingValue : Animated . Value < number > = new Value ( 0 )
320327 private onOpenStartValue : Animated . Value < number > = new Value ( 0 )
321328 private onOpenEndValue : Animated . Value < number > = new Value ( 0 )
322329 private onCloseStartValue : Animated . Value < number > = new Value ( 1 )
@@ -358,6 +365,10 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
358365 // current snap point desired
359366 this . snapPoint = currentSnapPoint ( )
360367
368+ if ( props . enabledBottomClamp ) {
369+ this . clampingValue . setValue ( snapPoints [ snapPoints . length - 1 ] )
370+ }
371+
361372 const masterClock = new Clock ( )
362373 const prevMasterDrag = new Value ( 0 )
363374 const wasRun : Animated . Value < number > = new Value ( 0 )
@@ -406,7 +417,14 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
406417 ) ,
407418 cond (
408419 greaterThan ( masterOffseted , snapPoints [ 0 ] ) ,
409- masterOffseted ,
420+ cond (
421+ and (
422+ props . enabledBottomClamp ? 1 : 0 ,
423+ greaterThan ( masterOffseted , this . clampingValue )
424+ ) ,
425+ this . clampingValue ,
426+ masterOffseted
427+ ) ,
410428 max (
411429 multiply (
412430 sub (
@@ -432,6 +450,13 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
432450 )
433451 }
434452
453+ componentDidUpdate ( _prevProps : Props , prevState : State ) {
454+ const { snapPoints } = this . state
455+ if ( this . props . enabledBottomClamp && snapPoints !== prevState . snapPoints ) {
456+ this . clampingValue . setValue ( snapPoints [ snapPoints . length - 1 ] )
457+ }
458+ }
459+
435460 private runSpring (
436461 clock : Animated . Clock ,
437462 value : Animated . Value < number > ,
0 commit comments