Cleanup of initial SVG rendering

This commit is contained in:
Jeff Avallone
2014-11-30 13:14:31 -05:00
parent b1a615daf0
commit 4decff56e7
3 changed files with 60 additions and 24 deletions
+13 -21
View File
@@ -1,35 +1,27 @@
export default {
render(container) {
this.container = container;
this.rect = this.container.rect().attr({
x: 5,
y: 5,
container.attr({ 'class': 'placeholder' });
this.rect = container.rect().attr({
rx: 10,
ry: 10,
fill: '#f00'
ry: 10
});
this.text = this.container.text(0, 0, this.textValue).attr({
fill: '#fff',
fontWeight: 'bold'
this.text = container.text().attr({
text: this.textValue
});
},
position() {
var box = this.text.getBBox();
var box = this.text.getBBox(),
margin = 5;
this.container.attr({
width: box.width + 20,
height: box.height + 20
});
this.text.attr({
x: 10,
y: box.height + 5
});
this.text.transform(Snap.matrix()
.translate(margin, box.height + margin));
this.rect.attr({
width: box.width + 10,
height: box.height + 10
width: box.width + 2 * margin,
height: box.height + 2 * margin
});
},