diff --git a/src/js/parser/javascript/base.js b/src/js/parser/javascript/base.js index 598a1c2..d2cc1aa 100644 --- a/src/js/parser/javascript/base.js +++ b/src/js/parser/javascript/base.js @@ -30,6 +30,15 @@ export default { return _.extend(this.container.getBBox(), this.getAnchor()); }, + normalizeBBox(box) { + return _.extend({ + atype: 'normalize', + ax: box.x, + ax2: box.x2, + ay: box.cy + }, box); + }, + transform(matrix) { return this.container.transform(matrix); }, @@ -94,6 +103,7 @@ export default { proxy(node) { this.anchorDebug = false; + this._proxy = node; return node.render(this.container); }, @@ -111,7 +121,8 @@ export default { }, spaceHorizontally(items, options) { - var verticalCenter = 0; + var verticalCenter = 0, + normalize = this.normalizeBBox; _.defaults(options, { padding: 0 @@ -123,17 +134,18 @@ export default { item.transform(Snap.matrix() .translate(offset, 0)); - box = item.getBBox(); - - verticalCenter = Math.max(verticalCenter, box.cy); + box = normalize(item.getBBox()); + verticalCenter = Math.max(verticalCenter, box.ay); return offset + options.padding + box.width; }, 0); _.each(items, item => { + var box = normalize(item.getBBox()); + item.transform(Snap.matrix() .add(item.transform().localMatrix) - .translate(0, verticalCenter - item.getBBox().cy)); + .translate(0, verticalCenter - box.ay)); }); }, diff --git a/src/js/parser/javascript/regexp.js b/src/js/parser/javascript/regexp.js index e265b80..7513bda 100644 --- a/src/js/parser/javascript/regexp.js +++ b/src/js/parser/javascript/regexp.js @@ -38,8 +38,8 @@ export default _.extend({}, Base, { 'M{box.width},{box.cy}m40,0q-10,0 -10,10V{bottom}' ].join(''), { box: containerBox, - top: _.first(matches).getBBox().cy + 10, - bottom: _.last(matches).getBBox().cy - 10 + top: _.first(matches).getBBox().ay + 10, + bottom: _.last(matches).getBBox().ay - 10 })); this.container.prepend( @@ -50,14 +50,14 @@ export default _.extend({}, Base, { makeConnectorLine(containerBox, match) { var box = match.getBBox(), - direction = box.cy > containerBox.cy ? 1 : -1, - distance = Math.abs(box.cy - containerBox.cy), + direction = box.ay > containerBox.cy ? 1 : -1, + distance = Math.abs(box.ay - containerBox.cy), pathStr; if (distance >= 15) { pathStr = [ - 'M10,{box.cy}m0,{shift}q0,{curve} 10,{curve}', - 'M{containerBox.width},{box.cy}m30,{shift}q0,{curve} -10,{curve}' + 'M10,{box.ay}m0,{shift}q0,{curve} 10,{curve}', + 'M{containerBox.width},{box.ay}m30,{shift}q0,{curve} -10,{curve}' ].join(''); } else { pathStr = [ @@ -73,7 +73,7 @@ export default _.extend({}, Base, { curve: 10 * direction, anchor: { x: box.x + 20, - y: box.cy - containerBox.cy + y: box.ay - containerBox.cy } }); },