最近我又给了 Dashcode 一个机会;)
这很棒。只是我认为没有很好的记录。我有一个 stackLayout 对象,其中只有两个视图,还有几个按钮可以将视图与转换交换。(视图显示大数组的数据,list
)动画和转换工作完美。问题是,当我在制作动画时按下一个按钮,动画又开始了,它看起来很难看(如果我有 n 个长度为 n 的数据源数组的视图,这应该不是问题,但这不是我的情况)。
我想在动画发生时禁用按钮。
动画完成后,是否有任何回调、委托或任何方式可以获得通知?
这就是我所做的:
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);
}