|
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 { |
@@ -269,6 +270,8 @@ export default class Card extends React.Component<Props> { |
269 | 270 | } |
270 | 271 |
|
271 | 272 | componentWillUnmount(): void { |
| 273 | + this.handleEndInteraction(); |
| 274 | + |
272 | 275 | // It might sometimes happen than animation will be unmounted |
273 | 276 | // during running. However, we need to invoke listener onClose |
274 | 277 | // manually in this case |
@@ -353,7 +356,24 @@ export default class Card extends React.Component<Props> { |
353 | 356 | finished: new Value(FALSE), |
354 | 357 | }; |
355 | 358 |
|
| 359 | + private interactionHandle: number | undefined; |
| 360 | + |
| 361 | + private handleStartInteraction = () => { |
| 362 | + if (this.interactionHandle === undefined) { |
| 363 | + this.interactionHandle = InteractionManager.createInteractionHandle(); |
| 364 | + } |
| 365 | + }; |
| 366 | + |
| 367 | + private handleEndInteraction = () => { |
| 368 | + if (this.interactionHandle !== undefined) { |
| 369 | + InteractionManager.clearInteractionHandle(this.interactionHandle); |
| 370 | + this.interactionHandle = undefined; |
| 371 | + } |
| 372 | + }; |
| 373 | + |
356 | 374 | private handleTransitionEnd = () => { |
| 375 | + this.handleEndInteraction(); |
| 376 | + |
357 | 377 | this.isRunningAnimation = false; |
358 | 378 | this.interpolatedStyle = this.getInterpolatedStyle( |
359 | 379 | this.props.styleInterpolator, |
@@ -391,6 +411,8 @@ export default class Card extends React.Component<Props> { |
391 | 411 | set(this.isVisible, isVisible), |
392 | 412 | startClock(this.clock), |
393 | 413 | call([this.isVisible], ([value]: ReadonlyArray<Binary>) => { |
| 414 | + this.handleStartInteraction(); |
| 415 | + |
394 | 416 | const { onTransitionStart } = this.props; |
395 | 417 | this.noAnimationStartedSoFar = false; |
396 | 418 | this.isRunningAnimation = true; |
@@ -532,8 +554,12 @@ export default class Card extends React.Component<Props> { |
532 | 554 | } = this.props; |
533 | 555 |
|
534 | 556 | if (isSwiping === TRUE) { |
| 557 | + this.handleStartInteraction(); |
| 558 | + |
535 | 559 | onGestureBegin && onGestureBegin(); |
536 | 560 | } else { |
| 561 | + this.handleEndInteraction(); |
| 562 | + |
537 | 563 | if (isSwipeCancelled === TRUE) { |
538 | 564 | onGestureCanceled && onGestureCanceled(); |
539 | 565 | } else { |
|
0 commit comments