Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,33 @@ var Navigator = React.createClass({
cb && cb();
});
},

/**
* Replace the previous scene with transition Animations.
* @param {object} route Route that replaces the previous scene.
*/
replaceWithAnimation: function (route) {
const currentLength = this.state.presentedIndex + 1;
const currentRouteStack = this.state.routeStack.slice(0, currentLength);
const animationConfigFromSceneConfigStack = this.state.sceneConfigStack.slice(0, currentLength);
const nextStack = currentRouteStack.concat([route]);
const destIndex = nextStack.length - 1;
const nextSceneConfig = this.props.configureScene(route, nextStack);
const nextAnimationConfigStack = animationConfigFromSceneConfigStack.concat([nextSceneConfig]);

const newStack = currentRouteStack.slice(0, currentLength - 1).concat([route]);
this._emitWillFocus(nextStack[destIndex]);
this.setState({
routeStack: nextStack,
sceneConfigStack: nextAnimationConfigStack,
},() => {
this._enableScene(destIndex);
this._transitionTo(destIndex, nextSceneConfig.defaultTransitionVelocity, null, () => {
// Immediately reset the route stack after the transition is completed
this.immediatelyResetRouteStack(newStack);
});
});
},

/**
* Replace the current scene with a new route.
Expand Down