最近我再次尝试 Dashcode ;)
太棒了。只是我认为没有很好的记录。
我有一个 stackLayout 对象,其中只有两个 View ,以及几个通过过渡交换 View 的按钮。( View 显示大数组的数据,列表
)
动画和过渡效果完美。问题是,当我在动画播放时按下按钮时,动画再次开始,它看起来很难看(如果我有长度为 n 的数据源数组的 n 个 View ,这应该不是问题,但这不是我的情况)。
我想在动画发生时禁用按钮。
是否有任何回调、委托(delegate)或任何方式可以在动画完成时收到通知?
这就是我所做的:
function _changeView(transitionDirection, newIndex){
//Create transition
var newTransition = new Transition(Transition.SWAP_TYPE, 0.9, Transition.EASE_TIMING);
newTransition.direction = transitionDirection;
//I only have two views. I use currentView's id to calculate not current view id and change text inside of it.
var stackLayout = document.getElementById('stackLayout').object;//stackLayout object
var nextViewId = (stackLayout.getCurrentView().id == 'view1')? '2':'1'; //
//change the text in the view that is going to appear
document.getElementById('text'+nextViewId).innerHTML = list[curIndex];
stackLayout.setCurrentViewWithTransition('view'+ nextViewId, newTransition, false);
}
function goPrevious(event)
{
curIndex--;
if(curIndex < 0){
curIndex = list.length-1;
}
_changeView(Transition.LEFT_TO_RIGHT_DIRECTION, curIndex);
}
function goNext(event)
{
curIndex++;
if(curIndex >list.length - 1){
curIndex = 0;
}
_changeView(Transition.RIGHT_TO_LEFT_DIRECTION, curIndex);
}
最佳答案
终于找到了这个问题的答案。我是这样做的:
document.getElementById('stackLayout').object.endTransitionCallback=function(stackLayout, oldView, newView) {
//PUT CODE HERE USING stackLayout, oldView, newView to show params
}
事实上,您可以在项目中的 StackLayout.js 文件中找到所有 stackLayout 方法和属性!!
希望这有帮助
关于javascript - 在 Dashcode/Dashboard 中制作动画时有更多控制权?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4335864/