When you select an object (in my example a polygon), it gets automatically moved to the Front. I'm searching for a way to prevent the movement on the z-axis or send it backwards after the selection, maybe someone can help?
Here is a link to a simple example: http://jsfiddle.net/98cuf9b7/1/
When you select one of the Polygons, it gets moved to the Front. I tried to send it backwards after the selection, but even if the "canvas.sendToBack(object)" function is called, it's still remains in the Front.
The code in my Example is:
var canvas = new fabric.Canvas('c');
var pol = new fabric.Polygon([
{x: 200, y: 0},
{x: 250, y: 50},
{x: 250, y: 100},
{x: 150, y: 100},
{x: 150, y: 50} ], {
left: 250,
top: 150,
angle: 0,
fill: 'green'
}
);
var pol2 = new fabric.Polygon([
{x: 200, y: 50},
{x: 200, y: 100},
{x: 100, y: 100},
{x: 100, y: 50} ], {
left: 300,
top: 200,
angle: 0,
fill: 'blue'
}
);
canvas.add(pol, pol2);
canvas.on('object:selected', function(event) {
var object = event.target;
canvas.sendToBack(object);
//object.sendToBack();
console.log("OK");
});