Compare commits

...

5 Commits

Author SHA1 Message Date
greenkeeper[bot]
357f0b6c71 chore(package): update tap to version 12.1.1
Closes #289
2018-12-12 07:39:41 +00:00
DD Liu
40cbe50238 Merge pull request #372 from LLK/greenkeeper/scratch-svg-renderer-0.2.0-prerelease.20181126212715
fix(package): update scratch-svg-renderer to version 0.2.0-prerelease…
2018-11-27 14:40:27 -05:00
Paul Kaplan
1a2b7a6253 Merge pull request #369 from towerofnix/fix-empty-speech-bubble-size
Fix empty speech bubbles showing up squished
2018-11-26 16:31:59 -05:00
greenkeeper[bot]
077d2f1d69 fix(package): update scratch-svg-renderer to version 0.2.0-prerelease.20181126212715
Closes #367
2018-11-26 21:28:37 +00:00
Florrie
4189377128 Fix empty speech bubbles showing up squished 2018-11-16 11:29:06 -04:00
2 changed files with 11 additions and 6 deletions

View File

@@ -38,7 +38,7 @@
"jsdoc": "^3.5.5",
"json": "^9.0.4",
"scratch-vm": "0.2.0-prerelease.20181024204838",
"tap": "^11.0.0",
"tap": "^12.1.1",
"travis-after-all": "^1.4.4",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^4.8.0",
@@ -53,7 +53,7 @@
"minilog": "3.1.0",
"raw-loader": "^0.5.1",
"scratch-storage": "^1.0.0",
"scratch-svg-renderer": "0.2.0-prerelease.20181024192149",
"scratch-svg-renderer": "0.2.0-prerelease.20181126212715",
"twgl.js": "4.4.0"
}
}

View File

@@ -145,11 +145,16 @@ class SVGTextBubble {
</g>`;
}
_getTextSize () {
const svgString = this._wrapSvgFragment(this._textFragment);
_getTextSize (textFragment) {
const svgString = this._wrapSvgFragment(textFragment);
if (!this._textSizeCache[svgString]) {
this._textSizeCache[svgString] = this.svgRenderer.measure(svgString);
if (this._textSizeCache[svgString].height === 0) {
// The speech bubble is empty, so use the height of a single line with content (or else it renders
// weirdly, see issue #302).
const dummyFragment = this._buildTextFragment('X');
this._textSizeCache[svgString] = this._getTextSize(dummyFragment);
}
}
return this._textSizeCache[svgString];
}
@@ -183,7 +188,7 @@ class SVGTextBubble {
let fragment = '';
const radius = 16;
const {x, y, width, height} = this._getTextSize();
const {x, y, width, height} = this._getTextSize(this._textFragment);
const padding = 10;
const fullWidth = Math.max(MIN_WIDTH, width) + (2 * padding);
const fullHeight = height + (2 * padding);