Skip to content

Commit 191d5d2

Browse files
committed
coerce arrowhead, arrowsize and startarrowsize only when it is needed
1 parent 42138e7 commit 191d5d2

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

src/components/annotations/common_defaults.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ module.exports = function handleAnnotationCommonDefaults(annIn, annOut, fullLayo
3636

3737
if(showArrow) {
3838
var arrowside = coerce('arrowside');
39-
var arrowhead = coerce('arrowhead');
40-
var arrowsize = coerce('arrowsize');
39+
var arrowhead;
40+
var arrowsize;
41+
42+
if(arrowside.indexOf('end') !== -1) {
43+
arrowhead = coerce('arrowhead');
44+
arrowsize = coerce('arrowsize');
45+
}
4146

4247
if(arrowside.indexOf('start') !== -1) {
4348
coerce('startarrowhead', arrowhead);
49+
coerce('startarrowsize', arrowsize);
4450
}
45-
coerce('startarrowsize', arrowsize);
4651
coerce('arrowcolor', borderOpacity ? annOut.bordercolor : Color.defaultLine);
4752
coerce('arrowwidth', ((borderOpacity && borderWidth) || 1) * 2);
4853
coerce('standoff');

src/components/annotations/draw_arrow_head.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ module.exports = function drawArrowHead(el3, ends, options) {
3939
var el = el3.node();
4040
var headStyle = ARROWPATHS[options.arrowhead || 0];
4141
var startHeadStyle = ARROWPATHS[options.startarrowhead || 0];
42-
var scale = (options.arrowwidth || 1) * options.arrowsize;
43-
var startScale = (options.arrowwidth || 1) * options.startarrowsize;
42+
var scale = (options.arrowwidth || 1) * (options.arrowsize || 1);
43+
var startScale = (options.arrowwidth || 1) * (options.startarrowsize || 1);
4444
var doStart = ends.indexOf('start') >= 0;
4545
var doEnd = ends.indexOf('end') >= 0;
4646
var backOff = headStyle.backoff * scale + options.standoff;

test/image/baselines/annotations.png

-5 Bytes
Loading
-11 Bytes
Loading
18 Bytes
Loading

0 commit comments

Comments
 (0)