如何在 Appcelerator 的动画方法中触发动作?
How to trigger actions during animate method with Appcelerator?
我有一个从绿色变为红色的简单进度条。 animate 方法在那里真的非常方便。但是有没有办法在动画 运行 时添加动作(例如,在 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
});
无论动画是什么,您都可以简单地使用 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);
我有一个从绿色变为红色的简单进度条。 animate 方法在那里真的非常方便。但是有没有办法在动画 运行 时添加动作(例如,在 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
});
无论动画是什么,您都可以简单地使用 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);