I am using fabric.js
Canvas event listener is not triggered while there is a change in canvas
var canvas = canvas(300,100);
Attaching event listener
canvas.on({
'mouse:up' : modifiedHandler,
'mouse:down' : modifiedHandler,
'object:modified' : modifiedHandler
});
This event listener is not triggered while there is change in canvas
var modifiedHandler = function (event) {
console.log('trigger') // Not triggered
};
This function returns canvas
function canvas(width, height) {
this.width = width;
this.height = height;
this.object = object();
function object() {
return new fabric.Canvas('id', {
selection: false,
height: this.height,
width: this.width
});
}
return this.object;
}
Adding the fiddle reference here
Declare modifiedHandler
first before you use it.
var modifiedHandler = function (event) {
alert('trigger'); // trigger
};
canvas.on({
'mouse:up' : modifiedHandler,
'mouse:down' : modifiedHandler,
'object:modified' : modifiedHandler
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.