Extracting a method to ease readability

This commit is contained in:
Jeff Avallone 2014-12-14 17:03:40 -05:00
parent d216c0fe5f
commit 97b816ffc9

View File

@ -29,7 +29,26 @@ export default _.extend({}, Base, {
});
containerBox = this.getBBox();
paths = _.map(matches, match => {
paths = _.map(matches, this.makeConnectorLine.bind(this, containerBox));
paths.push(Snap.format([
'M0,{box.cy}q10,0 10,-10V{top}',
'M0,{box.cy}q10,0 10,10V{bottom}',
'M{box.width},{box.cy}m40,0q-10,0 -10,-10V{top}',
'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
}));
this.container.prepend(
this.container.path(paths.join('')));
}).bind(this));
}
},
makeConnectorLine(containerBox, match) {
var box = match.getBBox(),
direction = box.cy > containerBox.cy ? 1 : -1,
distance = Math.abs(box.cy - containerBox.cy),
@ -57,23 +76,6 @@ export default _.extend({}, Base, {
y: box.cy - containerBox.cy
}
});
});
paths.push(Snap.format([
'M0,{box.cy}q10,0 10,-10V{top}',
'M0,{box.cy}q10,0 10,10V{bottom}',
'M{box.width},{box.cy}m40,0q-10,0 -10,-10V{top}',
'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
}));
this.container.prepend(
this.container.path(paths.join('')));
}).bind(this));
}
},
matches() {