Skip to content

Instantly share code, notes, and snippets.

@akmandev
Created October 13, 2016 13:01
Show Gist options
  • Save akmandev/c274b80c7158fd760042e1b8e23e92d5 to your computer and use it in GitHub Desktop.
Save akmandev/c274b80c7158fd760042e1b8e23e92d5 to your computer and use it in GitHub Desktop.
FabricJS - Get Item By ID
fabric.Canvas.prototype.getItem = function(id) {
var object = null,
objects = this.getObjects();
for (var i = 0, len = this.size(); i < len; i++) {
if (objects[i].id && objects[i].id === id) {
object = objects[i];
break;
}
}
return object;
};
@Chienle
Copy link

Chienle commented Sep 11, 2019

thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment