Adding transform method to Base node

This commit is contained in:
Jeff Avallone 2014-12-10 20:28:02 -05:00
parent 340d6b4859
commit f81ba6535f
4 changed files with 15 additions and 17 deletions

View File

@ -10,6 +10,10 @@ export default {
return this.container.getBBox(); return this.container.getBBox();
}, },
transform(matrix) {
return this.container.transform(matrix);
},
renderLabel(text) { renderLabel(text) {
var group = this.container.group() var group = this.container.group()
.addClass('label'); .addClass('label');
@ -86,10 +90,9 @@ export default {
}); });
_.reduce(items, (offset, item) => { _.reduce(items, (offset, item) => {
var element = item.container || item, var box;
box;
element.transform(Snap.matrix() item.transform(Snap.matrix()
.translate(offset, 0)); .translate(offset, 0));
box = item.getBBox(); box = item.getBBox();
@ -100,10 +103,8 @@ export default {
}, 0); }, 0);
_.each(items, item => { _.each(items, item => {
var element = item.container || item; item.transform(Snap.matrix()
.add(item.transform().localMatrix)
element.transform(Snap.matrix()
.add(element.transform().localMatrix)
.translate(0, verticalCenter - item.getBBox().cy)); .translate(0, verticalCenter - item.getBBox().cy));
}); });
}, },
@ -116,10 +117,9 @@ export default {
}); });
_.reduce(items, (offset, item) => { _.reduce(items, (offset, item) => {
var element = item.container || item, var box;
box;
element.transform(Snap.matrix() item.transform(Snap.matrix()
.translate(0, offset)); .translate(0, offset));
box = item.getBBox(); box = item.getBBox();
@ -130,10 +130,8 @@ export default {
}, 0); }, 0);
_.each(items, item => { _.each(items, item => {
var element = item.container || item; item.transform(Snap.matrix()
.add(item.transform().localMatrix)
element.transform(Snap.matrix()
.add(element.transform().localMatrix)
.translate(horizontalCenter - item.getBBox().cx, 0)); .translate(horizontalCenter - item.getBBox().cx, 0));
}); });
}, },

View File

@ -16,7 +16,7 @@ export default _.extend({}, Base, {
var box, paths = []; var box, paths = [];
this._content.position(); this._content.position();
this._content.container.transform(this._repeat.contentPosition()); this._content.transform(this._repeat.contentPosition());
box = this._content.getBBox(); box = this._content.getBBox();

View File

@ -6,7 +6,7 @@ export default _.extend({}, Base, {
_render() { _render() {
this.regexp.render(this.container.group()); this.regexp.render(this.container.group());
this.regexp.container.transform(Snap.matrix() this.regexp.transform(Snap.matrix()
.translate(10, 0)); .translate(10, 0));
this.start = this.container.circle() this.start = this.container.circle()

View File

@ -27,7 +27,7 @@ export default _.extend({}, Base, {
_position() { _position() {
this.regexp.position(); this.regexp.position();
this.positionLabeledBox(this.regexp.container, { this.positionLabeledBox(this.regexp, {
padding: 10 padding: 10
}); });
}, },