钛合金:左/右滑动窗

发布于 2024-11-19 09:53:34 字数 1105 浏览 1 评论 0原文

我想将当前打开的窗口向左滑动,然后从右侧滑动一个新窗口到屏幕上。我使用下面的代码,它完成了这项工作:

    var newWindow = Titanium.UI.createWindow({
        url:'new.js',
        backgroundImage:'ui/bg.gif',
        zIndex: 10,
        left: "100%",
        width: "100%"
    });


    var slide_it_left = Titanium.UI.createAnimation();
    slide_it_left.left = 0; // to put it back to the left side of the window
    //slide_it_left.curve = Titanium.UI.ANIMATION_CURVE_LINEAR;
    slide_it_left.duration = 500;

    var slide_it_right = Titanium.UI.createAnimation();
    slide_it_right.left = "-100%";
    //slide_it_right.curve = Titanium.UI.ANIMATION_CURVE_LINEAR;
    slide_it_right.duration = 500;    

    currentWindow.animate(slide_it_right);
    newWindow.open(slide_it_left);

但是,当两个窗口滑入/滑出时,它们之间似乎有 20px 的空间。我不知道这是怎么可能的,因为当前窗口的宽度为 100%,新窗口的宽度也是如此。我尝试通过调整曲线/缓动来隐藏该黑色空间,但没有好的结果,你仍然可以注意到无论如何,它们之间都是黑色的空间。有什么想法吗?谢谢!

更新: 通过使动画持续时间超慢,我注意到在开始和结束时它们完全对齐,但在中间却没有。通过使动画非常快,两个窗口之间的空间就很大。这意味着缓动一定发生了一些事情。这应该使动画在没有缓动的情况下进行,不是吗?:“Titanium.UI.ANIMATION_CURVE_LINEAR”。但不知怎的,它并没有解决问题..不知道宽松从何而来。

I want to slide the current open window to the left, and slide a new window from the right to on screen. I use the following code, which does the job:

    var newWindow = Titanium.UI.createWindow({
        url:'new.js',
        backgroundImage:'ui/bg.gif',
        zIndex: 10,
        left: "100%",
        width: "100%"
    });


    var slide_it_left = Titanium.UI.createAnimation();
    slide_it_left.left = 0; // to put it back to the left side of the window
    //slide_it_left.curve = Titanium.UI.ANIMATION_CURVE_LINEAR;
    slide_it_left.duration = 500;

    var slide_it_right = Titanium.UI.createAnimation();
    slide_it_right.left = "-100%";
    //slide_it_right.curve = Titanium.UI.ANIMATION_CURVE_LINEAR;
    slide_it_right.duration = 500;    

    currentWindow.animate(slide_it_right);
    newWindow.open(slide_it_left);

However, there seems that there is a space of 20px between the two windows when they slide in/out. I have no idea how that is possible, since the currentWindow has a width of 100% and the new one as well.. I tried to hide that black space, by adjusting curve/ease, but with no good result, you still can notice a black space in between them no matter what. Any ideas? Thanks!

UPDATE:
By making the animation duration super slow, I noticed that at the beginning and at the end they are perfectly aligned, but in between they are not. By making the animation to be very fast, the space between the two windows are big. Which means there must be something going on with the easing.. This should make the animation go without easing, no?: "Titanium.UI.ANIMATION_CURVE_LINEAR". But somehow it does not solve the problem.. Have no idea where the easing comes from.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

生寂 2024-11-26 09:53:34

如果您使用选项卡,只需在同一选项卡中打开新窗口即​​可。

tab1.open(win,{animated:true});

if you are using tabs, just open new window in the same tab.

tab1.open(win,{animated:true});
昇り龍 2024-11-26 09:53:34

如果用像素值设置窗口宽度和左/右是否有效?

Does it work if you set the window width and left/right with a pixel value?

请别遗忘我 2024-11-26 09:53:34

不,它不会起作用。无论如何,我在我的一个应用程序中有相同的要求,因此我没有使用窗口,而是使用视图并从右到左对它们进行动画处理,并使用应用程序全局堆栈管理它们。希望这有帮助。

No it will not work. Anyways I had same requirement in one of my apps so instead of using window I used Views and animated them from right to left and managed them with App global stack. Hope this helps.

如日中天 2024-11-26 09:53:34

由于此问题显示在搜索 appcelerator 幻灯片左侧动画的顶部,因此这对我有用

win.open({
    activityEnterAnimation: Ti.Android.R.anim.slide_in_left,
    activityExitAnimation: Ti.Android.R.anim.slide_out_right
});

检查此处的文档

http://docs.appcelerator.com/platform/latest/#!/api/openWindowParams

Since this question shows on the top of the search for appcelerator slide left animation here is what worked for me

win.open({
    activityEnterAnimation: Ti.Android.R.anim.slide_in_left,
    activityExitAnimation: Ti.Android.R.anim.slide_out_right
});

Check documentation here

http://docs.appcelerator.com/platform/latest/#!/api/openWindowParams

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文