From 1abd12b68be6358761411272117c830c1afd306a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 13 Jan 2016 13:26:59 -0800 Subject: [PATCH] configureScene: add routeStack in second argument Summary: Giving routeStack in second parameter of configureScene allows to do more advanced scene configuration. I have use-case where I can only determine the scene config from the navigation context (not only from the route object but also from where it's located). Closes https://github.com/facebook/react-native/pull/5254 Reviewed By: svcscm Differential Revision: D2828415 Pulled By: androidtrunkagent fb-gh-sync-id: 27b6c79b24cbc194e080541e9202ca84c55a0bc4 --- Libraries/CustomComponents/Navigator/Navigator.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index 47349d769..b87532e58 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -189,11 +189,11 @@ var Navigator = React.createClass({ propTypes: { /** * Optional function that allows configuration about scene animations and - * gestures. Will be invoked with the route and should return a scene - * configuration object + * gestures. Will be invoked with the route and the routeStack and should + * return a scene configuration object * * ``` - * (route) => Navigator.SceneConfigs.FloatFromRight + * (route, routeStack) => Navigator.SceneConfigs.FloatFromRight * ``` */ configureScene: PropTypes.func, @@ -293,7 +293,7 @@ var Navigator = React.createClass({ } return { sceneConfigStack: routeStack.map( - (route) => this.props.configureScene(route) + (route) => this.props.configureScene(route, routeStack) ), routeStack, presentedIndex: initialRouteIndex, @@ -368,7 +368,7 @@ var Navigator = React.createClass({ this.setState({ routeStack: nextRouteStack, sceneConfigStack: nextRouteStack.map( - this.props.configureScene + route => this.props.configureScene(route, nextRouteStack) ), presentedIndex: destIndex, activeGesture: null, @@ -913,7 +913,7 @@ var Navigator = React.createClass({ var nextStack = activeStack.concat([route]); var destIndex = nextStack.length - 1; var nextAnimationConfigStack = activeAnimationConfigStack.concat([ - this.props.configureScene(route), + this.props.configureScene(route, nextStack), ]); this._emitWillFocus(nextStack[destIndex]); this.setState({ @@ -981,7 +981,7 @@ var Navigator = React.createClass({ var nextRouteStack = this.state.routeStack.slice(); var nextAnimationModeStack = this.state.sceneConfigStack.slice(); nextRouteStack[index] = route; - nextAnimationModeStack[index] = this.props.configureScene(route); + nextAnimationModeStack[index] = this.props.configureScene(route, nextRouteStack); if (index === this.state.presentedIndex) { this._emitWillFocus(route);