Titanium:如何在 2 个窗口之间向左/向右或向上/向下滑动 [英] Titanium: how to transition Slide left/right or up/down between 2 windows

查看:24
本文介绍了Titanium:如何在 2 个窗口之间向左/向右或向上/向下滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题要解决.我有一天研究,但我还不能解决.我想将当前打开的窗口向左滑动,并将一个新窗口从右侧滑动到屏幕上.我该怎么做?

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?

推荐答案

您需要一个事件来触发此动画,可能是轻按按钮或只是简单地在窗口上滑动事件.在这种情况下,您只需简单地为 2 窗口的 left 属性设置动画,如下所示:

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);
});

这篇关于Titanium:如何在 2 个窗口之间向左/向右或向上/向下滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆