@@ -357,27 +357,33 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
357
357
const dispatchImmediateEvents = useCallback (
358
358
( fromValue : number , toValue : number ) => {
359
359
'worklet' ;
360
- if ( toValue > 0 && onSwipeableWillOpen ) {
361
- runOnJS ( onSwipeableWillOpen ) ( SwipeDirection . RIGHT ) ;
362
- } else if ( toValue < 0 && onSwipeableWillOpen ) {
363
- runOnJS ( onSwipeableWillOpen ) ( SwipeDirection . LEFT ) ;
364
- } else if ( onSwipeableWillClose ) {
360
+
361
+ if ( onSwipeableWillOpen && toValue !== 0 ) {
362
+ runOnJS ( onSwipeableWillOpen ) (
363
+ toValue > 0 ? SwipeDirection . RIGHT : SwipeDirection . LEFT
364
+ ) ;
365
+ }
366
+
367
+ if ( onSwipeableWillClose && toValue === 0 ) {
365
368
runOnJS ( onSwipeableWillClose ) (
366
369
fromValue > 0 ? SwipeDirection . LEFT : SwipeDirection . RIGHT
367
370
) ;
368
371
}
369
372
} ,
370
- [ onSwipeableWillClose , onSwipeableWillOpen ]
373
+ [ onSwipeableWillClose , onSwipeableWillOpen , rowState ]
371
374
) ;
372
375
373
376
const dispatchEndEvents = useCallback (
374
377
( fromValue : number , toValue : number ) => {
375
378
'worklet' ;
376
- if ( toValue > 0 && onSwipeableOpen ) {
377
- runOnJS ( onSwipeableOpen ) ( SwipeDirection . RIGHT ) ;
378
- } else if ( toValue < 0 && onSwipeableOpen ) {
379
- runOnJS ( onSwipeableOpen ) ( SwipeDirection . LEFT ) ;
380
- } else if ( onSwipeableClose ) {
379
+
380
+ if ( onSwipeableOpen && toValue !== 0 ) {
381
+ runOnJS ( onSwipeableOpen ) (
382
+ toValue > 0 ? SwipeDirection . RIGHT : SwipeDirection . LEFT
383
+ ) ;
384
+ }
385
+
386
+ if ( onSwipeableClose && toValue === 0 ) {
381
387
runOnJS ( onSwipeableClose ) (
382
388
fromValue > 0 ? SwipeDirection . LEFT : SwipeDirection . RIGHT
383
389
) ;
0 commit comments