Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mouse offset in canvas [fabric.js]

I've read 3-5 topics about mouse offset, but i still can't get where is the mess.

In my case everything works fine in 60%. In other 40% mouse is offset. Demo here.

Sometimes object position doesn't relate to mouse behavior. (IE & Chrome have the bigest mess)

I've tried to edit stylesheets and parent div but nothing. The worst thing: i don't see any regularity. I will be greatful for any help.

like image 898
Yevgen Avatar asked Jul 25 '12 18:07

Yevgen


1 Answers

You can do this:

canvas.on("after:render", function(){ canvas.calcOffset() });

I only do this after I create canvas. This is interim call when there is no resize event. That is when bug appears.

like image 191
Ashish Kaila Avatar answered Sep 22 '22 11:09

Ashish Kaila