Search code examples
javascriptcanvasfabricjstouch-event

Get the x and y after touch drag fabric JS


I have a little question about fabric JS :)

Here is the problem :

I have a function using the event : canvas.on('mouse:up', function(evn).. In this function i detect when the selectedObject is over another object.

When it's done, i remove the selected object like in this jsfiddle : https://jsfiddle.net/rekrah/jgruwse0/

The problem is : that doesn't work with touch event, i would like to know the touch "end" positions; or even get something like object:modified (which does not seem to work with touch event) triggered after a drag and drop with touch

Any help would be appreciated, thanks :)


Solution

  • Here is jsFiddle.

    Make use of getPointer method to get the pointer position.

    canvas.on('mouse:up', function(evn) {
     var point = canvas.getPointer(evn.e);
    }