Reputation: 456
I'm working with fabricjs. I have to know which one is currently working canvas while using multiple canvas(s). Sample code as follows,
<canvas id="canvas1" width="500" height="300">
<canvas id="canvas2" width="500" height="300">
<canvas id="canvas3" width="500" height="300">
var canvas1, canvas2, canvas3 = '';
canvas1 = new fabric.Canvas('canvas1');
canvas2 = new fabric.Canvas('canvas2');
canvas3 = new fabric.Canvas('canvas3');
From here, after adding some objects. I have to identify which one is active canvas.
Upvotes: 0
Views: 173
Reputation: 2610
Probably the simplest thing to do is to add an event handler for mouse over/out events each time you create a canvas, e.g.
var activeCanvas = null;
canvas1.on('mouse:over', function() {
activeCanvas = canvas1;
});
canvas1.on('mouse:out', function() {
activeCanvas = null;
});
// etc.
Upvotes: 1