Rename setTiming to applyAnimation

Summary:Given that you can do all kinds of animations other than `Animated.timing`, it made no sense to have `setTiming`. In addition, you can't intuitively tell that this is the callback where you would do custom animations.

The discussion took place on Discord with ericvicenti: https://discordapp.com/channels/102860784329052160/154015578669973504
Closes https://github.com/facebook/react-native/pull/6235

Differential Revision: D2999121

Pulled By: hedgerwang

fb-gh-sync-id: f587b865de11ba5e8dc9c430720252ffb5d12794
shipit-source-id: f587b865de11ba5e8dc9c430720252ffb5d12794
This commit is contained in:
Richard Lai 2016-03-08 23:31:27 -08:00 committed by Facebook Github Bot 0
parent 6470ff842b
commit f2483eb1ee
3 changed files with 12 additions and 12 deletions

View File

@ -78,7 +78,7 @@ class NavigationAnimatedExample extends React.Component {
navigationState={navigationState}
style={styles.animatedView}
renderOverlay={this._renderHeader}
setTiming={(pos, navState) => {
applyAnimation={(pos, navState) => {
Animated.timing(pos, {toValue: navState.index, duration: 1000}).start();
}}
renderScene={this._renderCard}

View File

@ -77,16 +77,16 @@ const defaultProps = {
* A controlled navigation view that renders a list of cards.
*/
class NavigationCardStack extends React.Component {
_applyAnimation: NavigationAnimationSetter;
_renderScene : NavigationSceneRenderer;
_setTiming: NavigationAnimationSetter;
constructor(props: Props, context: any) {
super(props, context);
}
componentWillMount() {
componentWillMount(): void {
this._applyAnimation = this._applyAnimation.bind(this);
this._renderScene = this._renderScene.bind(this);
this._setTiming = this._setTiming.bind(this);
}
shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
@ -103,7 +103,7 @@ class NavigationCardStack extends React.Component {
navigationState={this.props.navigationState}
renderOverlay={this.props.renderOverlay}
renderScene={this._renderScene}
setTiming={this._setTiming}
setTiming={this._applyAnimation}
style={[styles.animatedView, this.props.style]}
/>
);
@ -120,7 +120,7 @@ class NavigationCardStack extends React.Component {
);
}
_setTiming(
_applyAnimation(
position: NavigationAnimatedValue,
navigationState: NavigationParentState,
): void {

View File

@ -63,12 +63,12 @@ function compareScenes(
}
type Props = {
applyAnimation: NavigationAnimationSetter,
navigationState: NavigationParentState,
onNavigate: (action: any) => void,
renderScene: NavigationSceneRenderer,
renderOverlay: ?NavigationSceneRenderer,
renderScene: NavigationSceneRenderer,
style: any,
setTiming: NavigationAnimationSetter,
};
type State = {
@ -79,15 +79,15 @@ type State = {
const {PropTypes} = React;
const propTypes = {
applyAnimation: PropTypes.func,
navigationState: NavigationPropTypes.navigationState.isRequired,
onNavigate: PropTypes.func.isRequired,
renderScene: PropTypes.func.isRequired,
renderOverlay: PropTypes.func,
setTiming: PropTypes.func,
renderScene: PropTypes.func.isRequired,
};
const defaultProps = {
setTiming: (
applyAnimation: (
position: NavigationAnimatedValue,
navigationState: NavigationParentState,
) => {
@ -152,7 +152,7 @@ class NavigationAnimatedView
componentDidUpdate(lastProps: Props): void {
if (lastProps.navigationState.index !== this.props.navigationState.index) {
this.props.setTiming(
this.props.applyAnimation(
this.state.position,
this.props.navigationState,
lastProps.navigationState