最近我又给了 Dashcode 一个机会;)
这很棒。只是我认为没有很好的记录。
我有一个 stackLayout 对象,其中只有两个 View ,还有几个按钮可以将 View 与转换互换。( View 显示大数组的数据,list
)
动画和过渡效果完美。问题是,当我在制作动画时按下一个按钮,动画又开始了,它看起来很难看(如果我有 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/