Created
October 13, 2016 13:01
-
-
Save akmandev/c274b80c7158fd760042e1b8e23e92d5 to your computer and use it in GitHub Desktop.
FabricJS - Get Item By ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you so much!