Copy link to clipboard
Copied
Hi,
the last Chrome update has blocked touch events on canvas, such as moving with objects. You need now manually(!!) enter into chrome://flags and enabled Touch events API. The same problem is with Edge, here is it necessary set in about:flags.
When I display HTML5 canvas scene in a browser, it is not possible to move with the finger on the touch screen with the object "obj".
Is there some way to solve it in Adobe Animate code?
Here is my code:
//
_this=this
var offset;
function setobject(evt)
{
var p1 = _this.globalToLocal(evt.stageX, evt.stageY);
this.offset = {x: evt.currentTarget.x - p1.x,y: evt.currentTarget.y - p1.y};
}
function moveobject(evt)
{
var p = _this.globalToLocal(evt.stageX, evt.stageY);
evt.currentTarget.x = p.x + this.offset.x;
evt.currentTarget.y = p.y + this.offset.y;
}
this.obj.addEventListener("mousedown", setobject)
this.obj.addEventListener("pressmove", moveobject)
//
When I set for example "touch-action: none" in CSS, it seems to help but it does not work with a multi-touch.
Is there any solution?
Thank you!
Copy link to clipboard
Copied
Apparently they're only disabled on desktop versions of Chrome:
The ontouch* APIs default to disabled on desktop - Chrome Platform Status
Why would you be using touch events on the desktop? You should be using mouse events for desktop interaction.
Copy link to clipboard
Copied
Because I'm creating a program for kids on the touch screen with Windows. I need to put the figure in the example with a touch and not with mouse.
http://www.hrajeme-si.cz/iskolicka/hrajemesi/ukazka/sample1.html
Copy link to clipboard
Copied
Unless you're doing multi-touch interactions, you should be fine just using the mouse events. All touch screen drivers automatically simulate mouse events.
Copy link to clipboard
Copied
But have you tried my code? Or my sample on touch screen? Does not work. What code will work to move objects by touching with the browser's default setting to Touch event API disabled? And yes, I really need multi-touch for more kids...
Copy link to clipboard
Copied
Did you ever find an answer to this as i have the same issue!