11import React from 'react' ;
22import { Animated , Dimensions , PanResponderGestureState } from 'react-native' ;
33
4- import { useLogger } from '../contexts' ;
4+ import { useLogger , useGesture } from '../contexts' ;
55import {
66 usePanResponder ,
77 useSlideAnimation ,
@@ -81,6 +81,7 @@ export function AnimatedContainer({
8181 swipeable
8282} : AnimatedContainerProps ) {
8383 const { log } = useLogger ( ) ;
84+ const { panning } = useGesture ( ) ;
8485
8586 const { computeViewDimensions, height } = useViewDimensions ( ) ;
8687
@@ -93,6 +94,18 @@ export function AnimatedContainer({
9394 avoidKeyboard
9495 } ) ;
9596
97+ const disable = ! swipeable || ! isVisible ;
98+
99+ const onStart = React . useCallback ( ( ) => {
100+ log ( 'Swipe, pan start' ) ;
101+ panning . current = true ;
102+ } , [ log , panning ] ) ;
103+
104+ const onEnd = React . useCallback ( ( ) => {
105+ log ( 'Swipe, pan end' ) ;
106+ panning . current = false ;
107+ } , [ log , panning ] ) ;
108+
96109 const onDismiss = React . useCallback ( ( ) => {
97110 log ( 'Swipe, dismissing' ) ;
98111 animate ( 0 ) ;
@@ -118,7 +131,9 @@ export function AnimatedContainer({
118131 computeNewAnimatedValueForGesture,
119132 onDismiss,
120133 onRestore,
121- disable : ! swipeable
134+ onStart,
135+ onEnd,
136+ disable,
122137 } ) ;
123138
124139 React . useLayoutEffect ( ( ) => {
@@ -133,7 +148,7 @@ export function AnimatedContainer({
133148 style = { [ styles . base , styles [ position ] , animationStyles ] }
134149 // This container View is never the target of touch events but its subviews can be.
135150 // By doing this, tapping buttons behind the Toast is allowed
136- pointerEvents = { isVisible ? 'box-none' : 'none' }
151+ pointerEvents = 'box-none'
137152 { ...panResponder . panHandlers } >
138153 { children }
139154 </ Animated . View >
0 commit comments