MyStream
MyStream

Reputation: 2553

Triggering mousedown/touch and drag and release events in Fabric.js remotely

Using Fabric.js, is it possible to trigger the "mousedown", "move", and "mouseup" events from outside the canvas, e.g. with jQuery ui slider control?

I can't see any way to get a reference to each object so as to trigger events on it from outside canvas.

Upvotes: 0

Views: 3817

Answers (2)

MyStream
MyStream

Reputation: 2553

I just didn't see this example for how to access the objects:

http://fabricjs.com/controls/

This does what I needed.

Upvotes: 1

Kienz
Kienz

Reputation: 3517

Why you want to trigger events from outside? With the following function calls you can get access to objects:

var activeObject = canvas.getActiveObject();
var activeGroup = canvas.getActiveGroup();
var object1 = canvas.item(0); // item(1) ...

canvas.forEachObject(function(o) {
  //iterate over all existing objects
});

var objects = canvas.getObjects(); // returns array of all objects

Upvotes: 2

Related Questions