From f81ba6535f415d6c086c1d3459bfe451d3675bd8 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Wed, 10 Dec 2014 20:28:02 -0500 Subject: [PATCH] Adding transform method to Base node --- src/js/parser/javascript/base.js | 26 ++++++++++------------ src/js/parser/javascript/match_fragment.js | 2 +- src/js/parser/javascript/root.js | 2 +- src/js/parser/javascript/subexp.js | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/js/parser/javascript/base.js b/src/js/parser/javascript/base.js index a415d8b..d26feda 100644 --- a/src/js/parser/javascript/base.js +++ b/src/js/parser/javascript/base.js @@ -10,6 +10,10 @@ export default { return this.container.getBBox(); }, + transform(matrix) { + return this.container.transform(matrix); + }, + renderLabel(text) { var group = this.container.group() .addClass('label'); @@ -86,10 +90,9 @@ export default { }); _.reduce(items, (offset, item) => { - var element = item.container || item, - box; + var box; - element.transform(Snap.matrix() + item.transform(Snap.matrix() .translate(offset, 0)); box = item.getBBox(); @@ -100,10 +103,8 @@ export default { }, 0); _.each(items, item => { - var element = item.container || item; - - element.transform(Snap.matrix() - .add(element.transform().localMatrix) + item.transform(Snap.matrix() + .add(item.transform().localMatrix) .translate(0, verticalCenter - item.getBBox().cy)); }); }, @@ -116,10 +117,9 @@ export default { }); _.reduce(items, (offset, item) => { - var element = item.container || item, - box; + var box; - element.transform(Snap.matrix() + item.transform(Snap.matrix() .translate(0, offset)); box = item.getBBox(); @@ -130,10 +130,8 @@ export default { }, 0); _.each(items, item => { - var element = item.container || item; - - element.transform(Snap.matrix() - .add(element.transform().localMatrix) + item.transform(Snap.matrix() + .add(item.transform().localMatrix) .translate(horizontalCenter - item.getBBox().cx, 0)); }); }, diff --git a/src/js/parser/javascript/match_fragment.js b/src/js/parser/javascript/match_fragment.js index 21c273d..a56e334 100644 --- a/src/js/parser/javascript/match_fragment.js +++ b/src/js/parser/javascript/match_fragment.js @@ -16,7 +16,7 @@ export default _.extend({}, Base, { var box, paths = []; this._content.position(); - this._content.container.transform(this._repeat.contentPosition()); + this._content.transform(this._repeat.contentPosition()); box = this._content.getBBox(); diff --git a/src/js/parser/javascript/root.js b/src/js/parser/javascript/root.js index 43fd222..8beb210 100644 --- a/src/js/parser/javascript/root.js +++ b/src/js/parser/javascript/root.js @@ -6,7 +6,7 @@ export default _.extend({}, Base, { _render() { this.regexp.render(this.container.group()); - this.regexp.container.transform(Snap.matrix() + this.regexp.transform(Snap.matrix() .translate(10, 0)); this.start = this.container.circle() diff --git a/src/js/parser/javascript/subexp.js b/src/js/parser/javascript/subexp.js index 209f4c6..2d669f3 100644 --- a/src/js/parser/javascript/subexp.js +++ b/src/js/parser/javascript/subexp.js @@ -27,7 +27,7 @@ export default _.extend({}, Base, { _position() { this.regexp.position(); - this.positionLabeledBox(this.regexp.container, { + this.positionLabeledBox(this.regexp, { padding: 10 }); },