touchmove

You must Login before you can answer or comment on any questions.

Hi,

Could you explain me how works touchmove event plus.

in the example in the kithchensink (basic_animation)..for moving the circle. there is this code :

circle.addEventListener('touchmove', function(e)
{
    Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y );
    var newX = e.x + circle.animatedCenter.x - circle.width;
    var newY = e.y + circle.animatedCenter.y - circle.height;
    circle.animate({left:newX,top:newY, duration:1});
});
for me, it is more intuitive with this code (for y) :
circle.addEventListener('touchmove', function(e)
{
    Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y );
    var newY = e.y; 
    circle.animate({left:newX,top:newY, duration:1});
});
because e.y is the current position so circle is moved to the current position... what do you think ?

thanks

1 Answer

The difference between the first example and yours is that the circle will get positioned from the center of the circle in the first example, but in your example, the circle will get positioned from the top left coordinate of circle. So both examples will drag the circle just fine, the only difference will be whether the circle gets dragged from the top left of the circle or the center of the circle.

— answered 8 months ago by Anthony Decena
answer permalink
6 Comments
  • thanks.

    im confused...

    i have a window and a view which is positionned at top : -440, its height is 480. so only the 40px at the bottom of the view are visible (navBarContainer containted in the main view : viewInfosAlbum)

    i want to move the view down :

    i have this code :

    navBarContainer.addEventListener("touchmove", function(e) {
            viewInfosAlbum.animate({bottom:480 - e.y, duration:1});
        });
    but it doesn't work....i think i didn't understand very well how touchmove works..

    thanks

    — commented 8 months ago by Djamel ZAHAL

  • or this code :

    navBarContainer.addEventListener("touchmove", function(e) {
            var newY = viewInfosAlbum.top + e.y;
            viewInfosAlbum.animate({bottom:newY, duration:1});
        });
    top is set to -44 and e.y moves from 15 to 400 for example....so i will have -440+14....-440+400

    and the top of the view will change and the view go down..

    it doesn't work...

    thanks.

    — commented 8 months ago by Djamel ZAHAL

  • -440 not -44

    — commented 8 months ago by Djamel ZAHAL

  • Show 3 more comments

Your Answer

Think you can help? Login to answer this question!