Created
January 26, 2012 11:13
-
-
Save zubairov/1682293 to your computer and use it in GitHub Desktop.
fabric.js issue with groups
This file contains 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
var left = this.get('left'); | |
var top = this.get('top'); | |
var title = this.get('title'); | |
fabric.Image.fromURL(this.get('icon'), function(img) { | |
img.set('left', left + img.width / 2 + 6).set('top', top + img.height / 2 + 6); | |
var text = new fabric.Text(title, { | |
fontFamily: 'Delicious_500', | |
left: left + 38, | |
top: top + 90, | |
fontSize: 20, | |
textAlign: 'center' | |
}); | |
canvas.add(new fabric.Group([img, text])); | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Groups have somewhat limited behavior right now. You can only have one at any time and it should be the active one. If you need to add 2 objects to canvas just pass them to
add
—canvas.add(img, text)
. I'll be fixing groups soon.