Animate.spring 完成后调用函数
Calling function after Animate.spring has finished
我正在使用动画,以便弹出窗口从右侧进入。我为此使用以下代码 -
var toValue = 200;
if(this.state.fileMenu){
toValue = 0;
}
Animated.spring(
this.state.bounceValue,
{
toValue: toValue,
velocity: 3,
tension: 2,
friction: 5,
}
).start();
//I want to call a function here after the animation is finished.
this.setState({fileMenu: !this.state.fileMenu});
代码运行完美,看起来很棒,但是,我现在只想在动画完全结束时调用一个函数,并且严格只调用一次。只是想知道我该怎么做?不确定这是否是一个非常简单的问题。
start
带一个回调函数,动画结束后执行一次:
Animated.spring(
this.state.bounceValue,
{
toValue: toValue,
velocity: 3,
tension: 2,
friction: 5,
}
).start(() => doSmething());
我正在使用动画,以便弹出窗口从右侧进入。我为此使用以下代码 -
var toValue = 200;
if(this.state.fileMenu){
toValue = 0;
}
Animated.spring(
this.state.bounceValue,
{
toValue: toValue,
velocity: 3,
tension: 2,
friction: 5,
}
).start();
//I want to call a function here after the animation is finished.
this.setState({fileMenu: !this.state.fileMenu});
代码运行完美,看起来很棒,但是,我现在只想在动画完全结束时调用一个函数,并且严格只调用一次。只是想知道我该怎么做?不确定这是否是一个非常简单的问题。
start
带一个回调函数,动画结束后执行一次:
Animated.spring(
this.state.bounceValue,
{
toValue: toValue,
velocity: 3,
tension: 2,
friction: 5,
}
).start(() => doSmething());