Skip to content

Commit 2171995

Browse files
committed
feat: Further improvement to height calculation
1 parent 60684e9 commit 2171995

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ gulp.task('push-release', function (callback) {
267267
runSequence(
268268
'push-changes',
269269
'push-tags',
270-
'github-release',
271270
'npm-publish',
271+
'github-release',
272272
function (error) {
273273
if (error) {
274274
console.log(error.message);

src/builder.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -243,25 +243,28 @@ class TreeBuilder {
243243
static _nodeSize(nodes, width, textRenderer) {
244244
var maxWidth = 0;
245245
var maxHeight = 0;
246+
var tmpSvg = document.createElement('svg');
247+
document.body.appendChild(tmpSvg);
248+
246249
_.map(nodes, function(n) {
247250
var container = document.createElement('div');
248251
container.setAttribute('class', n.class);
249-
container.style.marginLeft = '5px';
250-
container.style.paddingTop = '5px';
251252
container.style.visibility = 'hidden';
252253
container.style.maxWidth = width + 'px';
253254

254255
var text = textRenderer(n.name, n.extra, n.textClass);
255256
container.innerHTML = text;
256257

257-
document.body.appendChild(container);
258+
tmpSvg.appendChild(container);
258259
var height = container.offsetHeight;
259-
document.body.removeChild(container);
260+
tmpSvg.removeChild(container);
260261

261262
maxHeight = Math.max(maxHeight, height);
262263
n.cHeight = height;
263264
n.cWidth = width;
264265
});
266+
document.body.removeChild(tmpSvg);
267+
265268
return [width, maxHeight];
266269
}
267270

0 commit comments

Comments
 (0)