最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why doesn't fabricjs canvas update properly after object.center()? - Stack Overflow

programmeradmin7浏览0评论
  1. Add an object to a fabric canvas
  2. call object.center()
  3. error: /

It seems the object is now in two places. It's visually rendered in the center, but the mouse cursor sees it as in its original position. If you click on the original position, the canvas updates properly and things behave as normal.

canvas.calcOffset() doesn't fix it (as it did here).

  1. Add an object to a fabric canvas
  2. call object.center()
  3. error: http://jsfiddle/tBnfL/

It seems the object is now in two places. It's visually rendered in the center, but the mouse cursor sees it as in its original position. If you click on the original position, the canvas updates properly and things behave as normal.

canvas.calcOffset() doesn't fix it (as it did here).

Share Improve this question edited May 23, 2017 at 12:02 CommunityBot 11 silver badge asked May 22, 2013 at 14:12 ChrisChris 7,2883 gold badges37 silver badges51 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 19

Turns out this is an open issue in fabricjs:

https://github./kangax/fabric.js/issues/642

The solution is to call object.setCoords() after changing the object's position.

The above has not worked for me, but the following code works fine

canvas.renderAll();
发布评论

评论列表(0)

  1. 暂无评论