钛 - 动画是 v. v. 波涛汹涌 [英] Titanium - animation is v. v. choppy

查看:34
本文介绍了钛 - 动画是 v. v. 波涛汹涌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个图片,我想下拉页面.

So i have an image that i want to drop down the page.

如果用户点击一个按钮,图片将停止下拉页面.

Should the user click a button, the image will stop said dropping down the page.

我使用 eventListener 'complete' 样式来执行此操作...并且它以某种方式起作用.问题是下降是波涛汹涌的〜令人恼火.

I've used the eventListener 'complete' style to execute this... and it works, in a fashion. The problem is that the dropping down is choppy ~ irritatingly so.

钛是否有更有效的方式来制作某种形式的简单动画?

Is there a more efficient way for titanium to do some form of simple animation?

这是一个代码片段:

    ballAnimation = Ti.UI.createAnimation({
            top: ballDown.top + 0.01*heightOfScreen,
            duration: someSpeedHere
        }, function(){
            if (hasBeenPressed){
                return;
            }
            else if (!hasBeenPressed && ballAnimation.top > lowestPointForBall){
                someFunctionHere(); //this isn't part of the problem. 
            } 
        }
    );

    ballAnimation.addEventListener('complete', function(){
        if (hasBeenPressed){
            return;
        }
        else if (!hasBeenPressed && ballAnimation.top > lowestPointForBall){
            someFunctionHere(); //this isn't part of the problem. 
        } else {
            ballAnimation.top = ballAnimation.top + 0.01*heightOfScreen;
            ballDown.animate(ballAnimation);
        } 
    });

    ballDown.animate(ballAnimation);

推荐答案

对于动画,建议使用具有如下转换的 2D 矩阵:

For animations it is advised to use a 2D matrix with a translation like this:

var translation = Titanium.UI.create2DMatrix(), deltaX, deltaY; // set the deltaX and deltaY according
translation = translation.translate(deltaX, deltaY);
ballDown.animate({
    transform : translation,
    duration : someSpeedHere
});

这篇关于钛 - 动画是 v. v. 波涛汹涌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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