Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private handleTransitionEnd = (
transition: { scene: Scene; navigation: NavigationProp },
lastTransition?: { scene: Scene; navigation: NavigationProp }
) => {
const {
navigationConfig,
navigation,
// @ts-ignore
onTransitionEnd = navigationConfig.onTransitionEnd,
} = this.props;
const transitionDestKey = transition.scene.route.key;
const isCurrentKey =
navigation.state.routes[navigation.state.index].key === transitionDestKey;
if (transition.navigation.state.isTransitioning && isCurrentKey) {
navigation.dispatch(
StackActions.completeTransition({
key: navigation.state.key,
toChildKey: transitionDestKey,
})
);
}
onTransitionEnd && onTransitionEnd(transition, lastTransition);
};
}
_onSceneFocus = route => {
this.props.navigation.dispatch(
StackActions.completeTransition({ toChildKey: route.key })
);
};
_removeScene = scene => {
const { navigation } = this.props;
navigation.dispatch(
NavigationActions.back({
key: scene.route.key,
immediate: true,
})
);
navigation.dispatch(StackActions.completeTransition());
};
const onCompleteAnimation = () => {
this.immediateIndex = null;
const backFromScene = scenes.find(s => s.index === toValue + 1);
if (backFromScene) {
navigation.dispatch(
NavigationActions.back({
key: backFromScene.route.key,
immediate: true,
})
);
navigation.dispatch(StackActions.completeTransition());
}
};
componentDidMount() {
const { navigation } = this.props;
if (navigation.state.isTransitioning) {
navigation.dispatch(
StackActions.completeTransition({
key: navigation.state.key,
})
);
}
}