-->

Titanium: how to transition Slide left/right or up

2020-08-01 02:26发布

问题:

I have a problem to solve. I research some day but i cant solve yet. I want to slide the current open window to the left, and slide a new window from the right to on screen. How can i do that?

回答1:

You'll need an event to fire this animation, possibly a tap on a button or just simply a swipe event on the window. In this event you just simply animate the 2 window's left property as follows:

var win1 = Ti.UI.createWindow({
    top: 0,
    left: 0,
    width: 320,
    height: 480
});

var win2 = Ti.UI.createWindow({
    top: 0,
    left: 320,
    width: 320,
    height: 480
});

win1.addEventListener('swipe', function(){
    var anim1 = Ti.UI.createAnimation({
        left: -320,
        duration: 1000
    });
    var anim2 = Ti.UI.createAnimation({
        left: 0,
        duration: 1000
    });
    win1.animate(anim1);
    win2.animate(anim2);
});