Using touch events with Createjs / Easeljs
Asked Answered
D

1

6

I'm trying to use touch events with Createjs / Easeljs objects. For example, I'm trying to attach a touchstart and touchmove event using addEventListener.

Touchstart and mousedown seems to work: I'm using a browser and a touch device to test it and it seems to work in both cases.

However, mousemove and touchmove doesn't seem to work. I though it was because I removed the stopPropagation and preventDefault methods, but I saw that Lanny McNie wrote that there is no need to do it in CreateJS 1.

I can't figure out why it doesn't work.

This is my code: http://pastebin.com/pqxWLNKG

Regards.

De answered 18/6, 2013 at 10:30 Comment(7)
Assuming it's enabled correctly, I'd suggest setting a breakpoint in the appropriate device specific code and see if it is a browser issue or something else.Sendoff
@WiredPrairie, I wish I could, I think that the remote debug console it's not enabled yet.De
Maybe add some logging instead? What device are you connecting?Sendoff
@WiredPrairie, I'm using a Keon Geeksphone device. I can use Adb Logcat, but the best I can see is this: pastebin.com/CVcC2mxbDe
Your device likely hasn't been tested with it... I wonder if it's not sending the events correctly (so maybe it's not a problem with the library as it is with the phone?)Sendoff
@WiredPrairie, is there any other way to test the touch event using any other kind of device or emulator? Is there any browser extesion or plugin to transform clicks into touchs?De
Do you have access to an iPad, iPhone, or modern Android device? You could get the Android emulator as part of the Android development kit.Sendoff
T
12

You can use the Touch class included with EaselJS to enable multi-touch - which translate into normal EaselJS mousedown/mousemove events. Check out the DragAndDrop demo: http://www.createjs.com/demos/easeljs/draganddrop

createjs.Touch.enable(stage);

Cheers.

Tilla answered 18/6, 2013 at 15:30 Comment(3)
thanks a lot. Is there any way to replace onPress, onMouseMove, onMouseOver and onMouseOut with addEventListener If I do createjs.Touch.enable(stage); Or does the Touch class only enable multi touch for that onAction methods?De
The touch class just proxies the existing interactions. The onAction callbacks are all deprecated - the event model is encouraged!Tilla
This was great! Until I saw this I was trying to use fastclick.js and couldn't accomplish what I was looking to do. Thanks!Walkin

© 2022 - 2024 — McMap. All rights reserved.