I
I
idze2014-12-27 13:33:19
JavaScript
idze, 2014-12-27 13:33:19

How to set event via fabric.Image.fromURL constructor?

var imgOptions = { 'left': 50, 'top': 550, 'selectable': false }
imgOptions.__eventListeners = {};
imgOptions.__eventListeners['mouseup'] = [];
imgOptions.__eventListeners['mouseup'].push(function () {
  console.log('mouseup event');
});

fabric.Image.fromURL('/url/mypng/', function(oImg) {
  canvas.add(oImg);
}, imgOptions);

Now there is such a code.
I spied, in the source code of the on () function, which sets events on the object, where you need to write callbacks.
And I brazenly shove them into the object's parameters (I also looked in the constructor's source code that this is possible) by analogy with the native on() method .
But how all the same to transfer events so that the constructor himself assigns them to the created object?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question