Skip to content
Closed
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 Libraries/CustomComponents/Navigator/Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,33 @@ var Navigator = React.createClass({
this.replaceAtIndex(route, this.state.presentedIndex);
},

/**
* 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 previous scene.
* @param {object} route Route that replaces the previous scene.
Expand Down