From e1c299453cebc55f1eb80919000bf2bf34ade00e Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Wed, 3 Dec 2014 20:35:26 -0500 Subject: [PATCH] Reducing the number of path elements that are generated --- src/js/parser/javascript/regexp.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/js/parser/javascript/regexp.js b/src/js/parser/javascript/regexp.js index 20f8aac..f6adb90 100644 --- a/src/js/parser/javascript/regexp.js +++ b/src/js/parser/javascript/regexp.js @@ -21,7 +21,8 @@ export default _.extend({}, Base, { totalHeight, verticalCenter, matches = this.matches(), - includeLines = (matches.length > 1); + includeLines = (matches.length > 1), + paths = []; _.invoke(matches, 'position'); @@ -49,23 +50,23 @@ export default _.extend({}, Base, { positions.each(pos => { var box = pos.content.getBBox(), direction = box.cy > verticalCenter ? 1 : -1, - pathStr, - path; + pathStr; pathStr = (verticalCenter === box.cy) ? 'M0,{center}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, target: box.cy - 10 * direction, side: box.x, 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)); } },