Skip to content

Commit 09647f1

Browse files
committed
lint Drawing.setPointGroupScale
- (x|y) -> (x|y)Scale to match Drawing.setTextPointsScale - pull out regex from function scope into module scope - do not return the scale (it is not used anywhere)
1 parent 2535b1a commit 09647f1

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

src/components/drawing/index.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,33 +1057,24 @@ drawing.setScale = function(element, x, y) {
10571057
return transform;
10581058
};
10591059

1060-
drawing.setPointGroupScale = function(selection, x, y) {
1061-
var t, scale, re;
1060+
var SCALE_RE = /\s*sc.*/;
10621061

1063-
x = x || 1;
1064-
y = y || 1;
1062+
drawing.setPointGroupScale = function(selection, xScale, yScale) {
1063+
xScale = xScale || 1;
1064+
yScale = yScale || 1;
10651065

1066-
if(x === 1 && y === 1) {
1067-
scale = '';
1068-
} else {
1069-
// The same scale transform for every point:
1070-
scale = ' scale(' + x + ',' + y + ')';
1071-
}
10721066

1073-
// A regex to strip any existing scale:
1074-
re = /\s*sc.*/;
1067+
// The same scale transform for every point:
1068+
var scale = (xScale === 1 && yScale === 1) ?
1069+
'' :
1070+
' scale(' + xScale + ',' + yScale + ')';
10751071

10761072
selection.each(function() {
1077-
// Get the transform:
1078-
t = (this.getAttribute('transform') || '').replace(re, '');
1073+
var t = (this.getAttribute('transform') || '').replace(SCALE_RE, '');
10791074
t += scale;
10801075
t = t.trim();
1081-
1082-
// Append the scale transform
10831076
this.setAttribute('transform', t);
10841077
});
1085-
1086-
return scale;
10871078
};
10881079

10891080
var TEXT_POINT_LAST_TRANSLATION_RE = /translate\([^)]*\)\s*$/;

0 commit comments

Comments
 (0)