Skip to content

Commit a01a1c1

Browse files
Compute slot size dynamically in SVG (#5236)
* Compute slot size dynamically in SVG * Format blockfactory.js with Prettier
1 parent ff47272 commit a01a1c1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

js/blockfactory.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ class SVG {
7474
this._expandY2 = 0;
7575
this._clampCount = 1;
7676
this._clampSlots = [1];
77-
this._slotSize = 21; // TODO: Compute this.
7877
this._arm = true;
7978
this._else = false;
8079
this._draw_inniess = true;
@@ -83,6 +82,7 @@ class SVG {
8382
this.margins = [0, 0, 0, 0];
8483
this._fontSize = 10;
8584
this._labelOffset = 0;
85+
this._computeSlotSize();
8686
}
8787

8888
// Attribute methods
@@ -145,6 +145,7 @@ class SVG {
145145
*/
146146
setScale(scale) {
147147
this._scale = scale;
148+
this._computeSlotSize();
148149
}
149150

150151
/**
@@ -208,6 +209,7 @@ class SVG {
208209
setstrokeWidth(stroke_width) {
209210
this._strokeWidth = stroke_width;
210211
this._calc_porch_params();
212+
this._computeSlotSize();
211213
}
212214

213215
/**
@@ -345,6 +347,14 @@ class SVG {
345347

346348
// SVG-related helper methods
347349

350+
/**
351+
* @private
352+
* @returns {void}
353+
*/
354+
_computeSlotSize() {
355+
this._slotSize = 2 * this._innieY2 + this._inniesSpacer + this._padding;
356+
}
357+
348358
/**
349359
* @private
350360
* @returns {void}

0 commit comments

Comments
 (0)