Moving spaceHorizontally and spaceVertically to util.js
This commit is contained in:
1 parent
870b2e6ed4
commit
a50ba68a21
8 files changed
+122
-119
No files matched your search
@@ -129,61 +129,6 @@ export default class Node {
|
||||
}
|
||||
}
|
||||
|
||||
spaceHorizontally(items, options) {
|
||||
var verticalCenter = 0;
|
||||
|
||||
options = _.defaults(options || {}, {
|
||||
padding: 0
|
||||
});
|
||||
|
||||
_.reduce(items, (offset, item) => {
|
||||
var box;
|
||||
|
||||
item.transform(Snap.matrix()
|
||||
.translate(offset, 0));
|
||||
|
||||
box = normalizeBBox(item.getBBox());
|
||||
verticalCenter = Math.max(verticalCenter, box.ay);
|
||||
|
||||
return offset + options.padding + box.width;
|
||||
}, 0);
|
||||
|
||||
for (var item of items) {
|
||||
let box = normalizeBBox(item.getBBox());
|
||||
|
||||
item.transform(Snap.matrix()
|
||||
.add(item.transform().localMatrix)
|
||||
.translate(0, verticalCenter - box.ay));
|
||||
}
|
||||
}
|
||||
|
||||
spaceVertically(items, options) {
|
||||
var horizontalCenter = 0;
|
||||
|
||||
options = _.defaults(options || {}, {
|
||||
padding: 0
|
||||
});
|
||||
|
||||
_.reduce(items, (offset, item) => {
|
||||
var box;
|
||||
|
||||
item.transform(Snap.matrix()
|
||||
.translate(0, offset));
|
||||
|
||||
box = item.getBBox();
|
||||
|
||||
horizontalCenter = Math.max(horizontalCenter, box.cx);
|
||||
|
||||
return offset + options.padding + box.height;
|
||||
}, 0);
|
||||
|
||||
for (var item of items) {
|
||||
item.transform(Snap.matrix()
|
||||
.add(item.transform().localMatrix)
|
||||
.translate(horizontalCenter - item.getBBox().cx, 0));
|
||||
}
|
||||
}
|
||||
|
||||
renderLabeledBox(label, content, options) {
|
||||
var label = this.container.text(0, 0, label)
|
||||
.addClass([this.type, 'label'].join('-')),
|
||||
|
||||
Reference in new issue
Block a user