Skip to content

Commit

Permalink
adjust dimensions and positioning after each step for easier debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
plegg75 committed Jun 19, 2018
1 parent 1a0834a commit 23dd42f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions svg_rendering/page/js-gen/transcript-generation.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,27 @@ var transcriptGeneration = (function () {

var computeLayout = function (currentIteration) {
visComponent.layout();
// move content to upper left corner and set witdh and height of container
function containerAdjustDimensions() {
var rootBBox = innerContainer.getBBox();
innerContainer.setAttribute("transform", "translate(" + (-rootBBox.x) + "," + (-rootBBox.y) + ")");
svgRoot.setAttribute("width", rootBBox.width);
svgRoot.setAttribute("height", rootBBox.height);
}
if (currentIteration < iterations) {
// push next layout computation to end of event queue
setTimeout(function () {
// console.log('Layout iteration ' + currentIteration);
computeLayout(currentIteration + 1);
// adjust dimensions and positioning after each step for easier debugging (can be omitted
// for production)
containerAdjustDimensions();
}, timeout);
} else {
var rootBBox = innerContainer.getBBox();
innerContainer.setAttribute("transform", "translate(" + (-rootBBox.x) + "," + (-rootBBox.y) + ")");
svgRoot.setAttribute("width", rootBBox.width);
svgRoot.setAttribute("height", rootBBox.height);

// document.body.removeChild(renderContainer);
containerAdjustDimensions();
if (typeof callback !== 'undefined') {
callback(renderContainer.firstChild);
}

}
};

Expand Down

0 comments on commit 23dd42f

Please sign in to comment.