Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate rotate around center in fabric js

Tags:

fabricjs

When you use one of the handle bars to rotate an object in fabricjs it will rotate the object around center. However, when using

tri.animate('angle', 45, {
  onChange: canvas.renderAll.bind(canvas)
});

It will rotate around the top-left corner. How to rotate around center just like with the handle bar?

Example: http://jsfiddle.net/QQ6eA/1/

like image 796
user3652885 Avatar asked Sep 03 '25 04:09

user3652885


1 Answers

Add:

originX: 'center',
originY: 'center',

to your triangle creation code.

like image 90
kolenda Avatar answered Sep 05 '25 02:09

kolenda