Skip to content

Commit

Permalink
feat: Further improvement to height calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikGartner committed Mar 8, 2016
1 parent 60684e9 commit 2171995
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ gulp.task('push-release', function (callback) {
runSequence(
'push-changes',
'push-tags',
'github-release',
'npm-publish',
'github-release',
function (error) {
if (error) {
console.log(error.message);
Expand Down
11 changes: 7 additions & 4 deletions src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,28 @@ class TreeBuilder {
static _nodeSize(nodes, width, textRenderer) {
var maxWidth = 0;
var maxHeight = 0;
var tmpSvg = document.createElement('svg');
document.body.appendChild(tmpSvg);

_.map(nodes, function(n) {
var container = document.createElement('div');
container.setAttribute('class', n.class);
container.style.marginLeft = '5px';
container.style.paddingTop = '5px';
container.style.visibility = 'hidden';
container.style.maxWidth = width + 'px';

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

document.body.appendChild(container);
tmpSvg.appendChild(container);
var height = container.offsetHeight;
document.body.removeChild(container);
tmpSvg.removeChild(container);

maxHeight = Math.max(maxHeight, height);
n.cHeight = height;
n.cWidth = width;
});
document.body.removeChild(tmpSvg);

return [width, maxHeight];
}

Expand Down

0 comments on commit 2171995

Please sign in to comment.