Skip to content

Commit

Permalink
fix: fixed transitions not triggering in release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
IjzerenHein committed Aug 30, 2019
1 parent 18f254e commit 56b11d3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
15 changes: 14 additions & 1 deletion src/createSharedElementScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ type PropsType = {
navigation: any;
};

function getActiveRouteState(route: any): any {
if (!route.routes || route.routes.length === 0 || route.index >= route.routes.length) {
return route;
} else {
return getActiveRouteState(route.routes[route.index]);
}
}

function createSharedElementScene(
Component: React.ComponentType<any>,
rendererData: ISharedElementRendererData
Expand Down Expand Up @@ -90,7 +98,12 @@ function createSharedElementScene(
};

private onDidFocus = () => {
rendererData.didActivateScene(this.sceneData);
const { navigation } = this.props;
const activeRoute = getActiveRouteState(navigation.state);
if (navigation.state.routeName === activeRoute.routeName) {
// console.log('onDidFocus: ', this.sceneData.name, activeRoute, this.props.navigation.state.routeName);
rendererData.didActivateScene(this.sceneData);
}
};
}

Expand Down
26 changes: 11 additions & 15 deletions src/createSharedElementStackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@ function createSharedElementEnabledNavigator(
typeof routeConfig === 'object' && routeConfig.screen
? routeConfig.screen
: routeConfig;
if (component.name !== 'Navigator') {
// console.log('Navigator detected, ignoring: ', component);
const wrappedComponent = createSharedElementScene(
component,
rendererData
);
if (component === routeConfig) {
wrappedRouteConfigs[key] = wrappedComponent;
} else {
wrappedRouteConfigs[key] = {
...routeConfig,
screen: wrappedComponent,
};
}
const wrappedComponent = createSharedElementScene(
component,
rendererData
);
if (component === routeConfig) {
wrappedRouteConfigs[key] = wrappedComponent;
} else {
wrappedRouteConfigs[key] = {
...routeConfig,
screen: wrappedComponent,
};
}
}

Expand Down Expand Up @@ -81,7 +78,6 @@ function createSharedElementStackNavigator(
);

class SharedElementRenderer extends React.Component {
static displayName = 'SharedElementRenderer';
private rendererData?: SharedElementRendererData;
render() {
return (
Expand Down

0 comments on commit 56b11d3

Please sign in to comment.