【问题标题】:Titanium - animation is v. v. choppy钛 - 动画是 v. v. 波涛汹涌
【发布时间】:2013-04-29 06:38:41
【问题描述】:

所以我有一张图片要下拉页面。

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

我已经使用 eventListener 'complete' 样式来执行此操作...并且它以某种方式工作。问题是下拉很不稳定~太烦人了。

有没有更有效的方式让钛制作某种形式的简单动画?

这是一段代码:

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

【问题讨论】:

    标签: titanium


    【解决方案1】:

    对于动画,建议使用带有如下平移的 2D 矩阵:

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

    【讨论】:

      猜你喜欢
      • 2015-12-20
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 2012-02-29
      • 2012-02-21
      • 1970-01-01
      • 2015-11-07
      相关资源
      最近更新 更多