Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Canvas drag and drop with touch

New Here ,
Nov 27, 2016 Nov 27, 2016

I created drag and drop but touchstart don't work.

var cl = this.cl;

createjs.Touch.enable(stage);

cl.addEventListener("touchstart", onTouch.bind(cl));

function onTouch(e) {

  thisCl.addChild(activeCl);

  canvas.addEventListener('touchmove', moveTouch);

  canvas.addEventListener("touchend", mUp);

}

function mUp() {

  canvas.removeEventListener('mousemove', move);

  canvas.addEventListener('touchmove', moveTouch);

}

function move() {

  cl.x = stage.mouseX;

  cl.y = stage.mouseY;

}

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2016 Nov 27, 2016

I'm not sure if this issue is still the case:

touchstart callback doesn't work · Issue #465 · CreateJS/EaselJS · GitHub

Does it work any better if you use mousedown or pressed? Could be worth reading this article:

EaselJS Tutorial: Mouse Interaction 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2016 Nov 27, 2016

Mouse Events don't work on mobile

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2016 Nov 27, 2016

I think most web sites work on mobile, even if they're only using mouse events.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2016 Nov 27, 2016

This is mouse events example test .

In mouse events PC work but in mobile don't work

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2016 Nov 27, 2016

This is a long shot, but try adding this:

createjs.Touch.enable(stage);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2016 Nov 27, 2016

If you want drag to work on mobile you need to stop the browser from taking control of your drag. Including this in the meta tag area of the HTML will stop unwanted highlighting and pinch to zoom:

<meta name="viewport" content="user-scalable=no">

<style type="text/css"> 

* { 

    -webkit-touch-callout: none; 

    -webkit-user-select: none; 

  -webkit-tap-highlight-color: rgba(0,0,0,0);

</style> 

Adding this to the <script> part of your HTML will stop the window from scrolling:

document.ontouchmove = function(e){ e.preventDefault(); }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2016 Dec 01, 2016
LATEST

I was set all that but don't work test

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines