Wrong bounding box after creating a selection. #10215
-
When selecting all objects inside the canvas and creating an https://jsfiddle.net/vhbx6prk/3/ const canvas = new fabric.Canvas("canvas")
canvas.setWidth(document.body.clientWidth)
canvas.setHeight(document.body.clientHeight)
canvas.on('after:render', () => {
canvas.contextContainer.strokeStyle = '#555';
canvas.forEachObject((obj) => {
var bound = obj.getBoundingRect();
canvas.contextContainer.strokeRect(
bound.left + 0.5,
bound.top + 0.5,
bound.width,
bound.height
);
});
});
const word1 = new fabric.Text("Example 1", {
left: 100,
top: 100,
width: 50,
height: 56,
})
const word2 = new fabric.Text("Example 1", {
left: 200,
top: 200,
width: 50,
height: 56,
fill: "red",
})
canvas.add(word1)
canvas.add(word2)
const selection = new fabric.ActiveSelection(canvas.getObjects(), {
canvas: canvas,
});
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
In fabric 5 the getBounding box is relative to the parent. I suggest you to see how the method is built in fabric 6 and just copy the code in your project if you need it in that way. If you are at the start of your project use fabric 6. |
Beta Was this translation helpful? Give feedback.
not sure this is what you are looking for:
https://jsfiddle.net/asturur/2rmuqa5n/3/