Skip to content

Commit c933cb2

Browse files
author
Xing
committed
fixed text moving down after redraw
1 parent e51c1a9 commit c933cb2

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

js/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ const Config = {
3636
attachmentMargin: 0.1,
3737
word2word_strategy: strategies.FARTHEST,
3838
word2link_strategy: strategies.CLOSEST,
39-
link2link_strategy: strategies.FARTHEST //CLOSEST sometimes causes overlaps - need to be a bit more rigorous when assigning slots - don't assign any slots that have the potential to overlap (when dragged manually)? - or let the buyer beware that this could happen - they can always move out of the way - right now it won't automatically overlap, but won't prevent a user from doing it.
39+
link2link_strategy: strategies.FARTHEST, //CLOSEST sometimes causes overlaps - need to be a bit more rigorous when assigning slots - don't assign any slots that have the potential to overlap (when dragged manually)? - or let the buyer beware that this could happen - they can always move out of the way - right now it won't automatically overlap, but won't prevent a user from doing it.
40+
redraw: 0
4041
};

js/render.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,7 @@ function redrawLinks(forceRedrawingAll) { //force redraw of all when resizing wi
769769
Object.keys(linkObjs).forEach(function(key) {
770770
if (linkObjs[key].needsUpdate || forceRedrawingAll == true) {
771771
////console.log(" link #" + key + " needsUpdate");
772+
Config.redraw = 1;
772773
drawLink(linkObjs[key]);
773774
linkObjs[key].needsUpdate = false;
774775
}
@@ -1316,6 +1317,7 @@ function calculateEndRow(idx, rowNum, link, percentagePadding, xPositions, linkS
13161317
function calculateLinkLabels(idx, rowNum, x, y, link, isHidden) {
13171318

13181319
var style;
1320+
var text;
13191321

13201322
if (rowNum % 2 == 0) {
13211323
style = styles.labelEvenFill.style;
@@ -1326,12 +1328,20 @@ function calculateLinkLabels(idx, rowNum, x, y, link, isHidden) {
13261328
var twh = link.textWH;
13271329

13281330
var rect = {x: (x - 2 - twh.w/2), y: (y - link.textStyle.maxHeight/2), w: (twh.w + 4), h: link.textStyle.maxHeight, style:style};
1329-
var text = {text: link.textStr, x: (x - twh.w/2), y: (y - link.textStyle.maxHeight/2 - link.textStyle.descent), style: (link.textStyle.style), visibility:true};
1331+
1332+
1333+
if (Config.redraw) {
1334+
text = {text: link.textStr, x: (x - twh.w/2), y: (y - link.textStyle.maxHeight/2), style: (link.textStyle.style), visibility:true};
1335+
}
1336+
else {
1337+
text = {text: link.textStr, x: (x - twh.w/2), y: (y - link.textStyle.maxHeight/2 - link.textStyle.descent), style: (link.textStyle.style), visibility:true};
1338+
}
13301339

13311340
console.log(" in calculateLinkLabels, idx = " + idx + ", rowNum = " + rowNum + ", rect = ");
13321341
console.log(rect);
13331342
console.log(" in calculateLinkLabels, text = ");
13341343
console.log(text);
1344+
console.log(link.textStyle.descent)
13351345

13361346
link.labels[idx] = {rect:rect, text:text};
13371347

js/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function getDescentForFont(str, fs) {
248248
textbbox = t.bbox();
249249
t.remove();
250250

251-
////console.log("in getMaxTextHeightForFont, y = " + textbbox.y + ", y2 = " + textbbox.y2);
251+
console.log("in getMaxTextHeightForFont, y = " + textbbox.y + ", y2 = " + textbbox.y2);
252252
return textbbox.y;
253253
}
254254

0 commit comments

Comments
 (0)