1
1
import React , { useRef } from 'react' ;
2
- import { Text , Animated , StyleSheet , View } from 'react-native' ;
2
+ import { Text , StyleSheet , View } from 'react-native' ;
3
3
4
4
import {
5
- Swipeable ,
6
5
GestureHandlerRootView ,
7
6
Pressable ,
8
7
} from 'react-native-gesture-handler' ;
@@ -48,55 +47,8 @@ function RightAction(prog: SharedValue<number>, drag: SharedValue<number>) {
48
47
) ;
49
48
}
50
49
51
- function LegacyLeftAction ( prog : any , drag : any ) {
52
- prog . addListener ( ( value : any ) => {
53
- console . log ( '[L] showLeftProgress:' , value . value ) ;
54
- } ) ;
55
- drag . addListener ( ( value : any ) => {
56
- console . log ( '[L] appliedTranslation:' , value . value ) ;
57
- } ) ;
58
-
59
- const trans = Animated . subtract ( drag , 50 ) ;
60
-
61
- return (
62
- < Animated . Text
63
- style = { [
64
- styles . leftAction ,
65
- {
66
- transform : [ { translateX : trans } ] ,
67
- } ,
68
- ] } >
69
- Text
70
- </ Animated . Text >
71
- ) ;
72
- }
73
-
74
- function LegacyRightAction ( prog : any , drag : any ) {
75
- prog . addListener ( ( value : any ) => {
76
- console . log ( '[L] showRightProgress:' , value . value ) ;
77
- } ) ;
78
- drag . addListener ( ( value : any ) => {
79
- console . log ( '[L] appliedTranslation:' , value . value ) ;
80
- } ) ;
81
-
82
- const trans = Animated . add ( drag , 50 ) ;
83
-
84
- return (
85
- < Animated . Text
86
- style = { [
87
- styles . rightAction ,
88
- {
89
- transform : [ { translateX : trans } ] ,
90
- } ,
91
- ] } >
92
- Text
93
- </ Animated . Text >
94
- ) ;
95
- }
96
-
97
50
export default function Example ( ) {
98
51
const reanimatedRef = useRef < SwipeableMethods > ( null ) ;
99
- const legacyRef = useRef < Swipeable > ( null ) ;
100
52
101
53
return (
102
54
< GestureHandlerRootView >
@@ -109,31 +61,27 @@ export default function Example() {
109
61
style = { styles . control }
110
62
onPress = { ( ) => {
111
63
reanimatedRef . current ! . openLeft ( ) ;
112
- legacyRef . current ?. openLeft ( ) ;
113
64
} } >
114
65
< Text > open left</ Text >
115
66
</ Pressable >
116
67
< Pressable
117
68
style = { styles . control }
118
69
onPress = { ( ) => {
119
70
reanimatedRef . current ! . close ( ) ;
120
- legacyRef . current ! . close ( ) ;
121
71
} } >
122
72
< Text > close</ Text >
123
73
</ Pressable >
124
74
< Pressable
125
75
style = { styles . control }
126
76
onPress = { ( ) => {
127
77
reanimatedRef . current ! . reset ( ) ;
128
- legacyRef . current ! . reset ( ) ;
129
78
} } >
130
79
< Text > reset</ Text >
131
80
</ Pressable >
132
81
< Pressable
133
82
style = { styles . control }
134
83
onPress = { ( ) => {
135
84
reanimatedRef . current ! . openRight ( ) ;
136
- legacyRef . current ! . openRight ( ) ;
137
85
} } >
138
86
< Text > open right</ Text >
139
87
</ Pressable >
@@ -155,20 +103,6 @@ export default function Example() {
155
103
</ ReanimatedSwipeable >
156
104
157
105
< View style = { styles . separator } />
158
-
159
- < Swipeable
160
- ref = { legacyRef }
161
- containerStyle = { styles . swipeable }
162
- friction = { 2 }
163
- leftThreshold = { 80 }
164
- enableTrackpadTwoFingerGesture
165
- rightThreshold = { 40 }
166
- renderLeftActions = { LegacyLeftAction }
167
- renderRightActions = { LegacyRightAction } >
168
- < Text > [Legacy] Swipe me!</ Text >
169
- </ Swipeable >
170
-
171
- < View style = { styles . separator } />
172
106
</ GestureHandlerRootView >
173
107
) ;
174
108
}
0 commit comments