Touch and drag

58 views
Skip to first unread message

isul

unread,
Aug 19, 2018, 7:03:45 AM8/19/18
to Crafty
Hi, how to dragging element with Touch? I have tried to code like this....

 Crafty.multitouch(true);
       
Crafty.mobile = true;
       
Crafty.e('2D, Canvas, Color, Multiway, Touch')
           
.attr({
                x
: 100,
                y
: 100,
                w
: 40,
                h
: 40
           
})
           
.color('green')
           
.bind('TouchMove', function(TouchPoint) {
               
this.x = TouchPoint.realX;
               
this.y = TouchPoint.realY;
           
});

but element could only move to right not to left, only could move to bottom not to top.

thanks.

Tim Martin

unread,
Aug 19, 2018, 1:17:23 PM8/19/18
to craf...@googlegroups.com
There's a special Draggable component that should provide that functionality: http://craftyjs.com/api/Draggable.html

If that isn't quite what you want, looking at the source for Draggable might be instructive.



--
You received this message because you are subscribed to the Google Groups "Crafty" group.
To unsubscribe from this group and stop receiving emails from it, send an email to craftyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

isul

unread,
Aug 20, 2018, 8:21:37 AM8/20/18
to Crafty
Thanks a lot for the respon. But draggable is working only for Mouse not Touch.

Ok, i will look at the source.
Reply all
Reply to author
Forward
0 new messages