Search code examples
javascriptdraggableeaseljs

EASELjs pressmove event of container with transformMatrix


I have questions please correct me, I dint't find anything about this after some research, You can point me to an answer if one exist. To be specific this is continuation of another post.

After applying a transformation matrix to the container element there is no dragging animation. I figured it out after reading the documentation:

transformMatrix Matrix2D

Inherited from DisplayObject: transformMatrix:318

If set, defines the transformation for this display object, overriding all other transformation properties (x, y, rotation, scale, skew).

Default: null

for dragging I used x and y proprieties of the target object

dragger.on("pressmove", function (evt) {
    evt.currentTarget.x = evt.stageX;
    evt.currentTarget.y = evt.stageY;
    canvasElement.update();
});

so now I think I have to change the matrix values to make dragging animation. Or there is another solution?


Here is the fiddle with the container with transformation matrix.


Solution

  • Right. If you apply a transformMatrix it overrides the other transformation properties. The most obvious solution, looking at your code is to just not use a matrix, and set the x and y properties.

    https://jsfiddle.net/n55jk201/11/

    The other option would be to use Matrix2D.translate(), or set tx/ty on the matrix directly:

    https://jsfiddle.net/n55jk201/12/

    Obviously there's a lot of code cleanup you could do, but hopefully that conveys the general idea.