Skip to content

Commit

Permalink
text box width cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Sep 26, 2018
1 parent 5b81d52 commit 35f590e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
13 changes: 5 additions & 8 deletions lib/render-wave-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ function findFirstChildByTagName (parent, name) {
}

function renderWaveElement (index, source, outputElement, waveSkin) {
var width, height, xmax = 0, i;

if (source.signal) {

insertSVGTemplate(index, outputElement, source, lane, waveSkin);
Expand All @@ -44,18 +42,17 @@ function renderWaveElement (index, source, outputElement, waveSkin) {
var content = parseWaveLanes(ret.lanes, lane);
var glengths = renderWaveLane(lanes, content, index, lane);

for (i in glengths) {
xmax = Math.max(xmax, (glengths[i] + ret.width[i]));
}
var xmax = glengths.reduce(function (res, len, i) {
return Math.max(res, len + ret.width[i]);
}, 0);

renderMarks(lanes, content, index, lane);
renderArcs(lanes, ret.lanes, index, source, lane);
renderGaps(lanes, ret.lanes, index, lane);
groups.insertBefore(jsonmlParse(renderGroups(ret.groups, index, lane)), null);
lane.xg = Math.ceil((xmax - lane.tgo) / lane.xs) * lane.xs;
width = (lane.xg + (lane.xs * (lane.xmax + 1)));
height = (content.length * lane.yo +
lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);
var width = (lane.xg + (lane.xs * (lane.xmax + 1)));
var height = (content.length * lane.yo + lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);

svgcontent.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
svgcontent.setAttribute('width', width);
Expand Down
13 changes: 5 additions & 8 deletions wavedrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,6 @@ function findFirstChildByTagName (parent, name) {
}

function renderWaveElement (index, source, outputElement, waveSkin) {
var width, height, xmax = 0, i;

if (source.signal) {

insertSVGTemplate(index, outputElement, source, lane, waveSkin);
Expand All @@ -1927,18 +1925,17 @@ function renderWaveElement (index, source, outputElement, waveSkin) {
var content = parseWaveLanes(ret.lanes, lane);
var glengths = renderWaveLane(lanes, content, index, lane);

for (i in glengths) {
xmax = Math.max(xmax, (glengths[i] + ret.width[i]));
}
var xmax = glengths.reduce(function (res, len, i) {
return Math.max(res, len + ret.width[i]);
}, 0);

renderMarks(lanes, content, index, lane);
renderArcs(lanes, ret.lanes, index, source, lane);
renderGaps(lanes, ret.lanes, index, lane);
groups.insertBefore(jsonmlParse(renderGroups(ret.groups, index, lane)), null);
lane.xg = Math.ceil((xmax - lane.tgo) / lane.xs) * lane.xs;
width = (lane.xg + (lane.xs * (lane.xmax + 1)));
height = (content.length * lane.yo +
lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);
var width = (lane.xg + (lane.xs * (lane.xmax + 1)));
var height = (content.length * lane.yo + lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);

svgcontent.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
svgcontent.setAttribute('width', width);
Expand Down
4 changes: 2 additions & 2 deletions wavedrom.min.js

Large diffs are not rendered by default.

13 changes: 5 additions & 8 deletions wavedrom.unpkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,6 @@ function findFirstChildByTagName (parent, name) {
}

function renderWaveElement (index, source, outputElement, waveSkin) {
var width, height, xmax = 0, i;

if (source.signal) {

insertSVGTemplate(index, outputElement, source, lane, waveSkin);
Expand All @@ -1946,18 +1944,17 @@ function renderWaveElement (index, source, outputElement, waveSkin) {
var content = parseWaveLanes(ret.lanes, lane);
var glengths = renderWaveLane(lanes, content, index, lane);

for (i in glengths) {
xmax = Math.max(xmax, (glengths[i] + ret.width[i]));
}
var xmax = glengths.reduce(function (res, len, i) {
return Math.max(res, len + ret.width[i]);
}, 0);

renderMarks(lanes, content, index, lane);
renderArcs(lanes, ret.lanes, index, source, lane);
renderGaps(lanes, ret.lanes, index, lane);
groups.insertBefore(jsonmlParse(renderGroups(ret.groups, index, lane)), null);
lane.xg = Math.ceil((xmax - lane.tgo) / lane.xs) * lane.xs;
width = (lane.xg + (lane.xs * (lane.xmax + 1)));
height = (content.length * lane.yo +
lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);
var width = (lane.xg + (lane.xs * (lane.xmax + 1)));
var height = (content.length * lane.yo + lane.yh0 + lane.yh1 + lane.yf0 + lane.yf1);

svgcontent.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
svgcontent.setAttribute('width', width);
Expand Down

0 comments on commit 35f590e

Please sign in to comment.