如何在使用Appcelerator的animate方法中触发操作?

时间:2017-08-09 08:38:42

标签: animation appcelerator

我有一个简单的进度条,从绿色变为红色。动画方法在那里非常方便。但有没有办法在动画运行时添加动作(例如,在1秒后显示标签)?

views.js:

<View id="progressBar" height="40%" width="100%" left="0%" backgroundColor="green" onClick="checkAnimation"/>

controller.js:

$.progressBar.animate({
    left: 0,
    width: "1%",
    backgroundColor: "red",
    duration: 2000  
});

1 个答案:

答案 0 :(得分:1)

您可以简单地使用setTimeout方法,无论正在运行什么动画,如下所示:

$.progressBar.animate({
    left: 0,
    width: "1%",
    backgroundColor: "red",
    duration: 2000  
});

setTimeout(function(){
   $.someLabel.visible = true; 
   // or
   $.someOtherLabel.text = "Label changed while animation is running...";
}, 1000);
相关问题