在DashCode/仪表板中进行动画时,更多控制权?
-
30-09-2019 - |
题
最近,我给Dashcode另一个镜头;)
这很棒。只是我认为没有充分记录。我有一个只有两个视图的堆叠对象,还有几个与过渡互换视图的按钮。(视图显示大型数组的数据, list
)动画和过渡完美。问题是,当我在动画动画的同时按下一个按钮再次启动时,它看起来很丑陋(如果我对长度为n的数据源阵列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);
}
解决方案
最终找到了答案。这是我的做法:
document.getElementById('stackLayout').object.endTransitionCallback=function(stackLayout, oldView, newView) {
//PUT CODE HERE USING stackLayout, oldView, newView to show params
}
实际上,您可以在项目中的stacklayout.js文件中找到所有堆叠的方法和属性!
希望这可以帮助
不隶属于 StackOverflow