Skip to content

Instantly share code, notes, and snippets.

function getZoomCompensatedBoundingRect(fabricObject){
//fabricObject is the object you want to get the boundingRect from
fabricObject.setCoords();
var boundingRect = fabricObject.getBoundingRect();
var zoom = canvas.getZoom();
var viewportMatrix = canvas.viewportTransform;
//there is a bug in fabric that causes bounding rects to not be transformed by viewport matrix
//this code should compensate for the bug for now