@@ -74,11 +74,11 @@ Animated.addWhitelistedUIProps({
7474const BottomSheetComponent = forwardRef < BottomSheet , BottomSheetProps > (
7575 (
7676 {
77- // animations
77+ // animations configurations
7878 animationDuration = DEFAULT_ANIMATION_DURATION ,
7979 animationEasing = DEFAULT_ANIMATION_EASING ,
8080 // configurations
81- initialSnapIndex = 0 ,
81+ index : initialSnapIndex = 0 ,
8282 snapPoints : _snapPoints ,
8383 handleHeight : _handleHeight ,
8484 topInset = 0 ,
@@ -90,8 +90,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
9090 containerTapGestureRef,
9191 containerTapGestureState,
9292 // animated nodes callback
93- animatedPosition : _animatedPosition ,
94- animatedPositionIndex : _animatedPositionIndex ,
93+ animatedPosition : _animatedPositionCallbackNode ,
94+ animatedIndex : _animatedIndexCallbackNode ,
9595 // callbacks
9696 onChange : _onChange ,
9797 // components
@@ -219,7 +219,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
219219 initialPosition,
220220 } ) ;
221221
222- const animatedPositionIndex = useMemo (
222+ // animated values
223+ const animatedIndex = useMemo (
223224 ( ) =>
224225 interpolate ( position , {
225226 inputRange : snapPoints . slice ( ) . reverse ( ) ,
@@ -231,6 +232,12 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
231232 } ) ,
232233 [ position , snapPoints ]
233234 ) ;
235+
236+ const animatedPosition = useMemo (
237+ ( ) => abs ( sub ( containerHeight , position ) ) ,
238+ [ containerHeight , position ]
239+ ) ;
240+
234241 /**
235242 * Scrollable animated props.
236243 */
@@ -453,18 +460,25 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
453460 const renderBackground = useCallback (
454461 ( ) =>
455462 BackgroundComponent ? (
456- < BackgroundComponent pointerEvents = "none" />
463+ < BackgroundComponent
464+ pointerEvents = "none"
465+ animatedIndex = { animatedIndex }
466+ animatedPosition = { animatedPosition }
467+ />
457468 ) : null ,
458- [ BackgroundComponent ]
469+ [ BackgroundComponent , animatedIndex , animatedPosition ]
459470 ) ;
460471 const renderHandle = useCallback (
461472 ( ) =>
462473 HandleComponent === null ? null : HandleComponent === undefined ? (
463474 < DefaultHandle />
464475 ) : (
465- < HandleComponent animatedPositionIndex = { animatedPositionIndex } />
476+ < HandleComponent
477+ animatedIndex = { animatedIndex }
478+ animatedPosition = { animatedPosition }
479+ />
466480 ) ,
467- [ HandleComponent , animatedPositionIndex ]
481+ [ HandleComponent , animatedIndex , animatedPosition ]
468482 ) ;
469483 return (
470484 < >
@@ -491,15 +505,15 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
491505 </ BottomSheetProvider >
492506 </ Animated . View >
493507
494- { _animatedPosition && (
508+ { _animatedPositionCallbackNode && (
495509 < Animated . Code
496- exec = { set ( _animatedPosition , abs ( sub ( containerHeight , position ) ) ) }
510+ exec = { set ( _animatedPositionCallbackNode , animatedPosition ) }
497511 />
498512 ) }
499513
500- { _animatedPositionIndex && (
514+ { _animatedIndexCallbackNode && (
501515 < Animated . Code
502- exec = { set ( _animatedPositionIndex , animatedPositionIndex ) }
516+ exec = { set ( _animatedIndexCallbackNode , animatedIndex ) }
503517 />
504518 ) }
505519 { /* <Animated.View pointerEvents="none" style={styles.debug}>
0 commit comments