ocanvas icon indicating copy to clipboard operation
ocanvas copied to clipboard

Events misplaced after css rotation of canvas container

Open xrmx opened this issue 13 years ago • 3 comments

If i rotate with css the canvas container the events associated to the objects are fired over a different area, in the test case the event added to the light blue object are fired a few pixels above the red one.

https://gist.github.com/3832805

xrmx avatar Oct 04 '12 10:10 xrmx

I consider this an edge case. If you feel strongly about this, please have a look at the source and submit a pull request with the fix. If I should do it, it will be pretty far down on my priority list.

koggdal avatar Oct 04 '12 10:10 koggdal

I think i can spend some time on it, any code hint is appreciated :)

xrmx avatar Oct 04 '12 10:10 xrmx

Great! You can look in tools.js, in the method transformPointerPosition. That will transform the pointer position in a way so it can be compared to an object in it's normal rotation state (for example a rectangle with rotation: 0 with no parents that are rotated). That method will loop through the whole parent chain of the object, and takes the origin and rotation of the parent objects into consideration. To do this fix, I would guess you have to add the canvas itself as the most outer parent, and detect the rotation and origin through CSS properties instead.

koggdal avatar Oct 04 '12 11:10 koggdal