fix: Transitioner await onTransitionStart

This commit is contained in:
Roberto Wesley Overdijk 2019-02-09 16:12:18 +01:00 committed by GitHub
parent f9f279e761
commit fac2462757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 26 deletions

View File

@ -174,39 +174,39 @@ class Transitioner extends React.Component {
await result;
}
}
});
// get the transition spec.
const transitionUserSpec = nextProps.configureTransition
? nextProps.configureTransition(
// get the transition spec.
const transitionUserSpec = nextProps.configureTransition
? nextProps.configureTransition(
this._transitionProps,
this._prevTransitionProps
)
: null;
: null;
const transitionSpec = {
...DefaultTransitionSpec,
...transitionUserSpec,
};
const transitionSpec = {
...DefaultTransitionSpec,
...transitionUserSpec,
};
const { timing } = transitionSpec;
delete transitionSpec.timing;
const { timing } = transitionSpec;
delete transitionSpec.timing;
// if swiped back, indexHasChanged == true && positionHasChanged == false
const positionHasChanged = position.__getValue() !== toValue;
if (indexHasChanged && positionHasChanged) {
timing(position, {
...transitionSpec,
toValue: nextProps.navigation.state.index,
}).start(() => {
// In case the animation is immediately interrupted for some reason,
// we move this to the next frame so that onTransitionStart can fire
// first (https://github.com/react-navigation/react-navigation/issues/5247)
requestAnimationFrame(this._onTransitionEnd);
});
} else {
this._onTransitionEnd();
}
// if swiped back, indexHasChanged == true && positionHasChanged == false
const positionHasChanged = position.__getValue() !== toValue;
if (indexHasChanged && positionHasChanged) {
timing(position, {
...transitionSpec,
toValue: nextProps.navigation.state.index,
}).start(() => {
// In case the animation is immediately interrupted for some reason,
// we move this to the next frame so that onTransitionStart can fire
// first (https://github.com/react-navigation/react-navigation/issues/5247)
requestAnimationFrame(this._onTransitionEnd);
});
} else {
this._onTransitionEnd();
}
});
}
}