@@ -61,7 +61,7 @@ type Props = {
61
61
disableHaptic ?: boolean
62
62
} ;
63
63
64
- type StateType = {
64
+ type State = {
65
65
dragX : Animated . Value ,
66
66
rowTranslation : Animated . Value ,
67
67
leftWidth : number | typeof undefined ,
@@ -71,7 +71,7 @@ type StateType = {
71
71
72
72
export type SwipeableProps = Props ;
73
73
74
- export default class Swipeable extends Component < Props , StateType > {
74
+ export default class Swipeable extends Component < Props , State > {
75
75
static displayName = 'IGNORE' ;
76
76
static defaultProps = {
77
77
friction : 1 ,
@@ -167,7 +167,6 @@ export default class Swipeable extends Component<Props, StateType> {
167
167
leftWidth + ( overshootLeft || overshootFriction > 1 ? 1 : 0 )
168
168
] ,
169
169
} ) ;
170
-
171
170
return transX ;
172
171
}
173
172
@@ -267,7 +266,10 @@ export default class Swipeable extends Component<Props, StateType> {
267
266
268
267
let toValue = 0 ;
269
268
if ( this . rowState === 0 ) {
270
- if ( this . _hasLeftActions && onToggleSwipeLeft && translationX > rowWidth * LEFT_TOGGLE_THRESHOLD && ! this . dragThresholdReached ) {
269
+ if ( Constants . isRTL && this . _hasLeftActions && onToggleSwipeLeft && translationX < - ( rowWidth * LEFT_TOGGLE_THRESHOLD ) && ! this . dragThresholdReached ) {
270
+ // Swipe left toggle RTL
271
+ toValue = - ( rowWidth * LEFT_TOGGLE_THRESHOLD ) ;
272
+ } else if ( this . _hasLeftActions && onToggleSwipeLeft && translationX > rowWidth * LEFT_TOGGLE_THRESHOLD && ! this . dragThresholdReached ) {
271
273
// Swipe left toggle
272
274
toValue = rowWidth * LEFT_TOGGLE_THRESHOLD ;
273
275
} else if ( ! onToggleSwipeLeft && fullSwipeLeft && translationX > rowWidth * fullLeftThreshold ) {
@@ -299,6 +301,7 @@ export default class Swipeable extends Component<Props, StateType> {
299
301
toValue = - rightWidth ;
300
302
}
301
303
}
304
+
302
305
this . _animateRow ( startOffsetX , toValue , velocityX / friction ) ;
303
306
} ;
304
307
@@ -336,6 +339,7 @@ export default class Swipeable extends Component<Props, StateType> {
336
339
...animationOptions
337
340
} ) . start ( ( { finished} ) => {
338
341
if ( finished ) {
342
+ // Final Callbacks
339
343
if ( toValue === rowWidth && onFullSwipeLeft ) {
340
344
onFullSwipeLeft ( ) ;
341
345
} else if ( toValue === - rowWidth && onFullSwipeRight ) {
@@ -354,7 +358,12 @@ export default class Swipeable extends Component<Props, StateType> {
354
358
}
355
359
} ) ;
356
360
357
- if ( ( toValue === rowWidth * LEFT_TOGGLE_THRESHOLD || this . dragThresholdReached ) && onToggleSwipeLeft ) {
361
+ // Transition Callbacks
362
+ if ( Constants . isRTL && this . _hasLeftActions && onToggleSwipeLeft && ( toValue === - ( rowWidth * LEFT_TOGGLE_THRESHOLD ) || this . dragThresholdReached ) ) {
363
+ // left toggle RTL
364
+ onToggleSwipeLeft ( { rowWidth, leftWidth, released : true , triggerHaptic : ! this . dragThresholdReached } ) ;
365
+ } else if ( this . _hasLeftActions && onToggleSwipeLeft && ( toValue === rowWidth * LEFT_TOGGLE_THRESHOLD || this . dragThresholdReached ) ) {
366
+ // left toggle
358
367
onToggleSwipeLeft ( { rowWidth, leftWidth, released : true , triggerHaptic : ! this . dragThresholdReached } ) ;
359
368
this . dragThresholdReached = false ;
360
369
} else if ( toValue === rowWidth && onWillFullSwipeLeft ) {
@@ -405,9 +414,10 @@ export default class Swipeable extends Component<Props, StateType> {
405
414
406
415
toggleLeft = ( ) => {
407
416
// Programmatically left toggle
408
- if ( this . _hasLeftActions ) {
417
+ const shouldAnimate = Constants . isRTL ? this . _hasRightActions : this . _hasLeftActions ;
418
+ if ( shouldAnimate ) {
409
419
const { rowWidth} = this . state ;
410
- this . _animateRow ( this . _currentOffset ( ) , rowWidth * LEFT_TOGGLE_THRESHOLD ) ;
420
+ this . _animateRow ( this . _currentOffset ( ) , ( rowWidth * LEFT_TOGGLE_THRESHOLD ) * ( Constants . isRTL ? - 1 : 1 ) ) ;
411
421
}
412
422
} ;
413
423
0 commit comments