Skip to content
Prev Previous commit
Next Next commit
fix || logic and optimize duration 0
  • Loading branch information
joenoon committed Apr 11, 2016
commit 1256e03cae02e9d3e4bb2a2f9dbfdb3a0bd65b52
14 changes: 9 additions & 5 deletions src/DefaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default class DefaultRenderer extends Component {
if (duration === null || duration === undefined) duration = navigationState.duration;
if (duration !== null && duration !== undefined) {
optionals.applyAnimation = function (pos, navState) {
Animated.timing(pos, {toValue: navState.index, duration}).start();
if (duration === 0) {
pos.setValue(navState.index);
} else {
Animated.timing(pos, {toValue: navState.index, duration}).start();
}
};
}
}
Expand All @@ -90,13 +94,13 @@ export default class DefaultRenderer extends Component {
_renderCard(/*NavigationSceneRendererProps*/ props) {
const isVertical = props.scene.navigationState.direction === "vertical";

const animationStyle = props.scene.navigationState.animationStyle || isVertical ?
const animationStyle = props.scene.navigationState.animationStyle || (isVertical ?
NavigationCardStackStyleInterpolator.forVertical(props) :
NavigationCardStackStyleInterpolator.forHorizontal(props);
NavigationCardStackStyleInterpolator.forHorizontal(props));

const panHandlers = props.scene.navigationState.panHandlers || isVertical ?
const panHandlers = props.scene.navigationState.panHandlers || (isVertical ?
NavigationCardStackPanResponder.forVertical(props) :
NavigationCardStackPanResponder.forHorizontal(props);
NavigationCardStackPanResponder.forHorizontal(props));

return (
<NavigationCard
Expand Down