mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-24 04:25:34 +08:00
feat: integrate InterationManager in stack
This commit is contained in:
committed by
satyajit.happy
parent
f57a91c417
commit
9563a27284
@@ -7,6 +7,7 @@ import {
|
||||
StyleProp,
|
||||
ViewStyle,
|
||||
Platform,
|
||||
InteractionManager,
|
||||
} from 'react-native';
|
||||
import Animated from 'react-native-reanimated';
|
||||
import {
|
||||
@@ -262,6 +263,8 @@ export default class Card extends React.Component<Props> {
|
||||
}
|
||||
|
||||
componentWillUnmount(): void {
|
||||
this.handleEndInteraction();
|
||||
|
||||
// It might sometimes happen than animation will be unmounted
|
||||
// during running. However, we need to invoke listener onClose
|
||||
// manually in this case
|
||||
@@ -342,7 +345,24 @@ export default class Card extends React.Component<Props> {
|
||||
finished: new Value(FALSE),
|
||||
};
|
||||
|
||||
private interactionHandle: number | undefined;
|
||||
|
||||
private handleStartInteraction = () => {
|
||||
if (this.interactionHandle === undefined) {
|
||||
this.interactionHandle = InteractionManager.createInteractionHandle();
|
||||
}
|
||||
};
|
||||
|
||||
private handleEndInteraction = () => {
|
||||
if (this.interactionHandle !== undefined) {
|
||||
InteractionManager.clearInteractionHandle(this.interactionHandle);
|
||||
this.interactionHandle = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
private handleTransitionEnd = () => {
|
||||
this.handleEndInteraction();
|
||||
|
||||
this.isRunningAnimation = false;
|
||||
this.interpolatedStyle = this.getInterpolatedStyle(
|
||||
this.props.styleInterpolator,
|
||||
@@ -380,6 +400,8 @@ export default class Card extends React.Component<Props> {
|
||||
set(this.isVisible, isVisible),
|
||||
startClock(this.clock),
|
||||
call([this.isVisible], ([value]: ReadonlyArray<Binary>) => {
|
||||
this.handleStartInteraction();
|
||||
|
||||
const { onTransitionStart } = this.props;
|
||||
this.noAnimationStartedSoFar = false;
|
||||
this.isRunningAnimation = true;
|
||||
@@ -517,8 +539,12 @@ export default class Card extends React.Component<Props> {
|
||||
} = this.props;
|
||||
|
||||
if (isSwiping === TRUE) {
|
||||
this.handleStartInteraction();
|
||||
|
||||
onGestureBegin && onGestureBegin();
|
||||
} else {
|
||||
this.handleEndInteraction();
|
||||
|
||||
if (isSwipeCancelled === TRUE) {
|
||||
onGestureCanceled && onGestureCanceled();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user