|
7 | 7 | StyleProp, |
8 | 8 | ViewStyle, |
9 | 9 | Platform, |
| 10 | + InteractionManager, |
10 | 11 | } from 'react-native'; |
11 | 12 | import Animated from 'react-native-reanimated'; |
12 | 13 | import { |
@@ -262,6 +263,8 @@ export default class Card extends React.Component<Props> { |
262 | 263 | } |
263 | 264 |
|
264 | 265 | componentWillUnmount(): void { |
| 266 | + this.handleEndInteraction(); |
| 267 | + |
265 | 268 | // It might sometimes happen than animation will be unmounted |
266 | 269 | // during running. However, we need to invoke listener onClose |
267 | 270 | // manually in this case |
@@ -342,7 +345,24 @@ export default class Card extends React.Component<Props> { |
342 | 345 | finished: new Value(FALSE), |
343 | 346 | }; |
344 | 347 |
|
| 348 | + private interactionHandle: number | undefined; |
| 349 | + |
| 350 | + private handleStartInteraction = () => { |
| 351 | + if (this.interactionHandle === undefined) { |
| 352 | + this.interactionHandle = InteractionManager.createInteractionHandle(); |
| 353 | + } |
| 354 | + }; |
| 355 | + |
| 356 | + private handleEndInteraction = () => { |
| 357 | + if (this.interactionHandle !== undefined) { |
| 358 | + InteractionManager.clearInteractionHandle(this.interactionHandle); |
| 359 | + this.interactionHandle = undefined; |
| 360 | + } |
| 361 | + }; |
| 362 | + |
345 | 363 | private handleTransitionEnd = () => { |
| 364 | + this.handleEndInteraction(); |
| 365 | + |
346 | 366 | this.isRunningAnimation = false; |
347 | 367 | this.interpolatedStyle = this.getInterpolatedStyle( |
348 | 368 | this.props.styleInterpolator, |
@@ -380,6 +400,8 @@ export default class Card extends React.Component<Props> { |
380 | 400 | set(this.isVisible, isVisible), |
381 | 401 | startClock(this.clock), |
382 | 402 | call([this.isVisible], ([value]: ReadonlyArray<Binary>) => { |
| 403 | + this.handleStartInteraction(); |
| 404 | + |
383 | 405 | const { onTransitionStart } = this.props; |
384 | 406 | this.noAnimationStartedSoFar = false; |
385 | 407 | this.isRunningAnimation = true; |
@@ -517,8 +539,12 @@ export default class Card extends React.Component<Props> { |
517 | 539 | } = this.props; |
518 | 540 |
|
519 | 541 | if (isSwiping === TRUE) { |
| 542 | + this.handleStartInteraction(); |
| 543 | + |
520 | 544 | onGestureBegin && onGestureBegin(); |
521 | 545 | } else { |
| 546 | + this.handleEndInteraction(); |
| 547 | + |
522 | 548 | if (isSwipeCancelled === TRUE) { |
523 | 549 | onGestureCanceled && onGestureCanceled(); |
524 | 550 | } else { |
|
0 commit comments