Skip to content

Commit f2483eb

Browse files
rclaiFacebook Github Bot 0
authored andcommitted
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 #6235 Differential Revision: D2999121 Pulled By: hedgerwang fb-gh-sync-id: f587b865de11ba5e8dc9c430720252ffb5d12794 shipit-source-id: f587b865de11ba5e8dc9c430720252ffb5d12794
1 parent 6470ff8 commit f2483eb

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Examples/UIExplorer/NavigationExperimental/NavigationAnimatedExample.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class NavigationAnimatedExample extends React.Component {
7878
navigationState={navigationState}
7979
style={styles.animatedView}
8080
renderOverlay={this._renderHeader}
81-
setTiming={(pos, navState) => {
81+
applyAnimation={(pos, navState) => {
8282
Animated.timing(pos, {toValue: navState.index, duration: 1000}).start();
8383
}}
8484
renderScene={this._renderCard}

Libraries/CustomComponents/NavigationExperimental/NavigationCardStack.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ const defaultProps = {
7777
* A controlled navigation view that renders a list of cards.
7878
*/
7979
class NavigationCardStack extends React.Component {
80+
_applyAnimation: NavigationAnimationSetter;
8081
_renderScene : NavigationSceneRenderer;
81-
_setTiming: NavigationAnimationSetter;
8282

8383
constructor(props: Props, context: any) {
8484
super(props, context);
8585
}
8686

87-
componentWillMount() {
87+
componentWillMount(): void {
88+
this._applyAnimation = this._applyAnimation.bind(this);
8889
this._renderScene = this._renderScene.bind(this);
89-
this._setTiming = this._setTiming.bind(this);
9090
}
9191

9292
shouldComponentUpdate(nextProps: Object, nextState: Object): boolean {
@@ -103,7 +103,7 @@ class NavigationCardStack extends React.Component {
103103
navigationState={this.props.navigationState}
104104
renderOverlay={this.props.renderOverlay}
105105
renderScene={this._renderScene}
106-
setTiming={this._setTiming}
106+
setTiming={this._applyAnimation}
107107
style={[styles.animatedView, this.props.style]}
108108
/>
109109
);
@@ -120,7 +120,7 @@ class NavigationCardStack extends React.Component {
120120
);
121121
}
122122

123-
_setTiming(
123+
_applyAnimation(
124124
position: NavigationAnimatedValue,
125125
navigationState: NavigationParentState,
126126
): void {

Libraries/NavigationExperimental/NavigationAnimatedView.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ function compareScenes(
6363
}
6464

6565
type Props = {
66+
applyAnimation: NavigationAnimationSetter,
6667
navigationState: NavigationParentState,
6768
onNavigate: (action: any) => void,
68-
renderScene: NavigationSceneRenderer,
6969
renderOverlay: ?NavigationSceneRenderer,
70+
renderScene: NavigationSceneRenderer,
7071
style: any,
71-
setTiming: NavigationAnimationSetter,
7272
};
7373

7474
type State = {
@@ -79,15 +79,15 @@ type State = {
7979
const {PropTypes} = React;
8080

8181
const propTypes = {
82+
applyAnimation: PropTypes.func,
8283
navigationState: NavigationPropTypes.navigationState.isRequired,
8384
onNavigate: PropTypes.func.isRequired,
84-
renderScene: PropTypes.func.isRequired,
8585
renderOverlay: PropTypes.func,
86-
setTiming: PropTypes.func,
86+
renderScene: PropTypes.func.isRequired,
8787
};
8888

8989
const defaultProps = {
90-
setTiming: (
90+
applyAnimation: (
9191
position: NavigationAnimatedValue,
9292
navigationState: NavigationParentState,
9393
) => {
@@ -152,7 +152,7 @@ class NavigationAnimatedView
152152

153153
componentDidUpdate(lastProps: Props): void {
154154
if (lastProps.navigationState.index !== this.props.navigationState.index) {
155-
this.props.setTiming(
155+
this.props.applyAnimation(
156156
this.state.position,
157157
this.props.navigationState,
158158
lastProps.navigationState

0 commit comments

Comments
 (0)