Moving normalizeBBox to util.js
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { normalizeBBox } from '../../util.js';
|
||||
import _ from 'lodash';
|
||||
import Q from 'q';
|
||||
|
||||
@@ -7,8 +8,8 @@ export default {
|
||||
definedProperties: {
|
||||
_anchor: {
|
||||
get: function() {
|
||||
var start = this.normalizeBBox(_.first(this.items).getBBox()),
|
||||
end = this.normalizeBBox(_.last(this.items).getBBox()),
|
||||
var start = normalizeBBox(_.first(this.items).getBBox()),
|
||||
end = normalizeBBox(_.last(this.items).getBBox()),
|
||||
matrix = this.transform().localMatrix;
|
||||
|
||||
return {
|
||||
@@ -47,11 +48,11 @@ export default {
|
||||
padding: 10
|
||||
});
|
||||
|
||||
prev = this.normalizeBBox(_.first(items).getBBox());
|
||||
prev = normalizeBBox(_.first(items).getBBox());
|
||||
paths = _.map(items.slice(1), item => {
|
||||
var path;
|
||||
|
||||
next = this.normalizeBBox(item.getBBox());
|
||||
next = normalizeBBox(item.getBBox());
|
||||
path = `M${prev.ax2},${prev.ay}H${next.ax}`;
|
||||
prev = next;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { customEvent } from '../../util.js';
|
||||
import { customEvent, normalizeBBox } from '../../util.js';
|
||||
import _ from 'lodash';
|
||||
import Q from 'q';
|
||||
|
||||
@@ -54,14 +54,6 @@ export default class Node {
|
||||
return _.extend(this.container.getBBox(), this.anchor);
|
||||
}
|
||||
|
||||
normalizeBBox(box) {
|
||||
return _.extend({
|
||||
ax: box.x,
|
||||
ax2: box.x2,
|
||||
ay: box.cy
|
||||
}, box);
|
||||
}
|
||||
|
||||
transform(matrix) {
|
||||
return this.container.transform(matrix);
|
||||
}
|
||||
@@ -150,14 +142,14 @@ export default class Node {
|
||||
item.transform(Snap.matrix()
|
||||
.translate(offset, 0));
|
||||
|
||||
box = this.normalizeBBox(item.getBBox());
|
||||
box = normalizeBBox(item.getBBox());
|
||||
verticalCenter = Math.max(verticalCenter, box.ay);
|
||||
|
||||
return offset + options.padding + box.width;
|
||||
}, 0);
|
||||
|
||||
for (var item of items) {
|
||||
let box = this.normalizeBBox(item.getBBox());
|
||||
let box = normalizeBBox(item.getBBox());
|
||||
|
||||
item.transform(Snap.matrix()
|
||||
.add(item.transform().localMatrix)
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export function customEvent(name, detail) {
|
||||
var evt = document.createEvent('Event');
|
||||
evt.initEvent(name, true, true);
|
||||
evt.detail = detail;
|
||||
return evt;
|
||||
}
|
||||
|
||||
|
||||
export function normalizeBBox(box) {
|
||||
return _.extend({
|
||||
ax: box.x,
|
||||
ax2: box.x2,
|
||||
ay: box.cy
|
||||
}, box);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user