Reducing the number of path elements that are generated
This commit is contained in:
parent
5a000ec302
commit
e1c299453c
@ -21,7 +21,8 @@ export default _.extend({}, Base, {
|
|||||||
totalHeight,
|
totalHeight,
|
||||||
verticalCenter,
|
verticalCenter,
|
||||||
matches = this.matches(),
|
matches = this.matches(),
|
||||||
includeLines = (matches.length > 1);
|
includeLines = (matches.length > 1),
|
||||||
|
paths = [];
|
||||||
|
|
||||||
_.invoke(matches, 'position');
|
_.invoke(matches, 'position');
|
||||||
|
|
||||||
@ -49,23 +50,23 @@ export default _.extend({}, Base, {
|
|||||||
positions.each(pos => {
|
positions.each(pos => {
|
||||||
var box = pos.content.getBBox(),
|
var box = pos.content.getBBox(),
|
||||||
direction = box.cy > verticalCenter ? 1 : -1,
|
direction = box.cy > verticalCenter ? 1 : -1,
|
||||||
pathStr,
|
pathStr;
|
||||||
path;
|
|
||||||
|
|
||||||
pathStr = (verticalCenter === box.cy) ?
|
pathStr = (verticalCenter === box.cy) ?
|
||||||
'M0,{center}H{side}' :
|
'M0,{center}H{side}' :
|
||||||
'M0,{center}q10,0 10,{d}V{target}q0,{d} 10,{d}H{side}';
|
'M0,{center}q10,0 10,{d}V{target}q0,{d} 10,{d}H{side}';
|
||||||
|
|
||||||
path = self.container.path(Snap.format(pathStr, {
|
paths.push(Snap.format(pathStr, {
|
||||||
center: verticalCenter,
|
center: verticalCenter,
|
||||||
target: box.cy - 10 * direction,
|
target: box.cy - 10 * direction,
|
||||||
side: box.x,
|
side: box.x,
|
||||||
d: 10 * direction
|
d: 10 * direction
|
||||||
}));
|
}));
|
||||||
|
|
||||||
path.clone().transform(Snap.matrix()
|
|
||||||
.scale(-1, 1, center + 20, 0));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.container.path(paths.join(''))
|
||||||
|
.clone().transform(Snap.matrix()
|
||||||
|
.scale(-1, 1, center + 20, 0));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user