Titanium - animation v. V. Choppy

So, I have an image that I want to release on the page.

If the user clicks the button, the image will stop it, discarding the page.

I used the full-screen eventListener style to accomplish this ... and it works in some way. The problem is that dumping is pretty ~ annoying.

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

Here is the code snippet:

    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);
+1
source share
1 answer

For animations, it is recommended to use a 2D matrix with the following translation:

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

Source: https://habr.com/ru/post/1531231/


All Articles