Más control al hacer animaciones en Dashcode / tablero de instrumentos?
-
30-09-2019 - |
Pregunta
Hace poco me estoy dando otra oportunidad a Dashcode;)
Es muy bueno. Es sólo que creo que no está bien documentado.
Tengo un objeto stackLayout con sólo dos puntos de vista en el mismo, y un par de botones que intercambian las vistas con una transición. (Vistas muestran los datos de una gran variedad, list
)
Animaciones y transiciones funcionan perfecto. El problema es que cuando se presiona un botón, mientras que la animación de la animación se inicia de nuevo y se ve feo (Si tuviera n vistas para una matriz de origen de datos de longitud n este DEBERÍAMOS ser un problema, pero esto no es mi caso).
Quiero desactivar los botones, mientras que la animación está teniendo lugar.
¿Hay alguna devolución de llamada, delegado, o de cualquier manera que pueda recibir una notificación cuando se termine la animación?
Esto es lo que he hecho:
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);
}
Solución
Finalmente encontró la respuesta a esto. He aquí cómo lo hice:
document.getElementById('stackLayout').object.endTransitionCallback=function(stackLayout, oldView, newView) {
//PUT CODE HERE USING stackLayout, oldView, newView to show params
}
De hecho, usted puede encontrar todos los métodos stackLayout y propiedades en el archivo StackLayout.js en su proyecto !!
Espero que esto ayude