Extracting code to layout elements vertically

This commit is contained in:
Jeff Avallone
2014-12-09 20:08:34 -05:00
parent 0f97afd880
commit 7082a670d6
3 changed files with 76 additions and 62 deletions
+5 -20
View File
@@ -29,31 +29,16 @@ export default _.extend({}, Base, {
},
position() {
var box, offset = 0;
var box;
_.each(this.parts.elements, (part => {
var box;
_.invoke(this.parts.elements, 'position');
part.position();
part.container.transform(Snap.matrix()
.translate(0, offset));
box = part.getBBox();
offset += box.height + 5;
}).bind(this));
this.spaceVertically(this.parts.elements, {
padding: 5
});
box = this.partContainer.getBBox();
_.each(this.parts.elements, (part => {
var partBox = part.getBBox();
part.container.transform(Snap.matrix()
.add(part.container.transform().localMatrix)
.translate(box.cx - partBox.cx, 0));
}).bind(this));
this.box.attr({
width: box.width + 10,
height: box.height + 10