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.

Cod1ngFree
  • 1,873
  • 6
  • 21
  • 33
  • 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. – WiredPrairie Jun 18 '13 at 11:02
  • @WiredPrairie, I wish I could, I think that the remote debug console it's not enabled yet. – Cod1ngFree Jun 18 '13 at 11:07
  • Maybe add some logging instead? What device are you connecting? – WiredPrairie Jun 18 '13 at 11:08
  • @WiredPrairie, I'm using a Keon Geeksphone device. I can use Adb Logcat, but the best I can see is this: http://pastebin.com/CVcC2mxb – Cod1ngFree Jun 18 '13 at 11:22
  • 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?) – WiredPrairie Jun 18 '13 at 12:17
  • @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? – Cod1ngFree Jun 18 '13 at 13:10
  • 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. – WiredPrairie Jun 18 '13 at 14:07

1 Answers1

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.

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • 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? – Cod1ngFree Jun 18 '13 at 15:50
  • The touch class just proxies the existing interactions. The onAction callbacks are all deprecated - the event model is encouraged! – Lanny Jun 18 '13 at 20:14
  • 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! – Joe Shock Jun 23 '15 at 18:15