Skip to content

Commit f899b2e

Browse files
davepackkelset
authored andcommitted
Fixes inputRange on headerStyleInterpolator (react-navigation#2873)
1 parent e1da55e commit f899b2e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/views/Header/HeaderStyleInterpolator.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,18 @@ function forLeft(props: NavigationSceneRendererProps): AnimatedViewStyleProp {
2727

2828
if (!interpolate) return { opacity: 0 };
2929

30-
const activeScene = scenes.find((item: NavigationScene) => item.isActive);
31-
const activeIndex = scenes.findIndex(
32-
(item: NavigationScene) => item === activeScene
33-
);
34-
const currentIndex = scenes.findIndex(
35-
(item: NavigationScene) => item === scene
36-
);
37-
const deviation = Math.abs((activeIndex - currentIndex) / 2);
3830
const { first, last } = interpolate;
3931
const index = scene.index;
4032

4133
return {
4234
opacity: position.interpolate({
43-
inputRange: [first, first + deviation, index, last - deviation, last],
35+
inputRange: [
36+
first,
37+
first + Math.abs(index - first) / 2,
38+
index,
39+
last - Math.abs(last - index) / 2,
40+
last,
41+
],
4442
outputRange: ([0, 0, 1, 0, 0]: Array<number>),
4543
}),
4644
};

0 commit comments

Comments
 (0)