@@ -34,19 +34,18 @@ export const FancySwiper = ({
34
34
} : FancySwiperProps ) => {
35
35
const remainingCards = useMemo ( ( ) => cards . reverse ( ) , [ cards . length ] )
36
36
const swiper = useRef < Animated . ValueXY > ( new Animated . ValueXY ( ) ) . current
37
+ const swiperSwipedCard = useRef < Animated . ValueXY > ( new Animated . ValueXY ( ) ) . current
37
38
38
39
const panResponder = PanResponder . create ( {
39
40
onStartShouldSetPanResponder : ( ) => true ,
40
41
onPanResponderMove : ( _ , { dx, dy, x0 } ) => {
41
42
// if we're 25% left of the screen when swiping then we update normally
42
43
if ( x0 <= whiffHitSlop ) {
43
- swiper . setValue ( { x : dx , y : dy } )
44
- // otherwise we clamp the dragging to avoid up/down/right movement
44
+ swiperSwipedCard . setValue ( { x : dx , y : dy } )
45
45
} else {
46
+ // otherwise we clamp the dragging to avoid up/down/right movement
46
47
swiper . setValue ( { x : Math . min ( dx , 0 ) , y : 0 } )
47
48
}
48
- // works but not allows a nice whiff
49
- // swiper.setValue({ x: Math.min(dx, 0), y: 0 })
50
49
} ,
51
50
onPanResponderRelease : ( _ , { dx, dy, x0 } ) => {
52
51
const isFullSwipe = Math . abs ( dx ) > SWIPE_MAGNITUDE
@@ -84,6 +83,7 @@ export const FancySwiper = ({
84
83
} ) . start ( ( ) => {
85
84
// revert the pan responder to its initial position
86
85
swiper . setValue ( { x : 0 , y : 0 } )
86
+ swiperSwipedCard . setValue ( { x : - width , y : 0 } )
87
87
onSwipeLeft ( )
88
88
} )
89
89
}
@@ -102,8 +102,21 @@ export const FancySwiper = ({
102
102
}
103
103
104
104
const handleRightWhiff = ( ) => {
105
- swiper . setValue ( { x : 0 , y : 0 } )
105
+ // swiper.setValue({ x: 0, y: 0 })
106
+ swiperSwipedCard . setValue ( { x : 0 , y : 0 } )
106
107
onWhiffRight ?.( )
108
+ // Animated.timing(swiperSwipedCard, {
109
+ // easing: Easing.cubic,
110
+ // toValue: { x: 0, y: 0 },
111
+ // duration: 300,
112
+ // useNativeDriver: true,
113
+ // }).start(() => {
114
+ // swiper.setValue({ x: 0, y: 0 })
115
+ // swiperSwipedCard.setValue({ x: 0, y: 0 })
116
+ // onWhiffRight?.()
117
+ // })
118
+ // swiper.setValue({ x: 0, y: 0 })
119
+ // onWhiffRight?.()
107
120
}
108
121
109
122
return (
@@ -126,6 +139,7 @@ export const FancySwiper = ({
126
139
key = { card . artworkId }
127
140
artworkId = { card . artworkId }
128
141
swiper = { swiper }
142
+ swiperSwipedCard = { swiperSwipedCard }
129
143
isTopCard = { isTopCard }
130
144
isSecondCard = { isSecondCard }
131
145
isSwipedCard = { isSwipedCard }
0 commit comments