I have two canvas layer, stacked on each other. A top layer named top
and a bottom layer named bottom
. On the top
layer I add some objects that are transparent
and only show their handles. The bottom
layer should clone
the objects from the top
, change some properties and draw them.
This works fines as long as I'm only moving a single object on the top
layer. When I select a group
of objects and start to move the whole group, something breaks. On the top
layer everything works fine but the objects on the bottom
layer are drawn into the upper left corner of the canvas. This is corrected only if I start to drag a single object around again.
I hope that someone can take a look and may have an idea what's going wrong :)
var top = new fabric.Canvas("top", {renderOnAddRemove:false});
var bottom = new fabric.Canvas("bottom", {renderOnAddRemove:false});
var update = function () {
bottom.clear().add.apply(bottom, top.getObjects().map(function (o) {
return o.clone().set({
selectable: false,
hasBorders: false,
hasControls: false,
fill: "rgba(255,0,0,.5)",
globalCompositeOperation: "xor"
});
})).renderAll();
};
top.on({
"object:modified": update
});