Skip to content

Commit e9df4c3

Browse files
author
Xing
committed
fixed issue with links not adjusting after row change
1 parent 2f91d91 commit e9df4c3

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

js/annotate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function checkSlotAvailabity(num, slotArr) {
306306
//type: 1 = word; 2 = link
307307
function checkAndUpdateWordToWordSlots(link, startSlot) { //, minWord, minSide, maxWord, maxSide) {
308308
var wo1, wo2, side1, side2;
309-
309+
console.log("in checkandupdatewordtowordslots");
310310
wo1 = link.rootMinWord;
311311
wo2 = link.rootMaxWord;
312312
side1 = link.rootMinSide;

js/interact.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function updateAllLinks() {
8484
}
8585
}
8686

87+
8788
function updateLinks(link) {
8889

8990
var arr = [link];
@@ -97,6 +98,17 @@ function updateLinks(link) {
9798

9899
}
99100

101+
function updateLinkRow(row) {
102+
for (let item of linkObjs) {
103+
let minRow = item.rootMinWord.row.idx;
104+
let maxRow = item.rootMaxWord.row.idx;
105+
if( row >= minRow || maxRow >= row )
106+
{
107+
item.needsUpdate = true;
108+
}
109+
}
110+
}
111+
100112

101113
/** Update words that have been dragged or pushed by a dragged word, and collect the links that need to be updated **/
102114
function updateWords() {
@@ -441,7 +453,7 @@ function setUpLeftHandleDraggable(word) {
441453
var returnVal = dragLeftHandle(x, word.leftHandle.bbox().y, word);
442454

443455
updateWords();
444-
456+
445457
redrawLinks(false);//actually - only redraw links that moving this word would affect + this row
446458
prevX = x;
447459
return returnVal;
@@ -901,6 +913,7 @@ function moveWordDownARow(w) {
901913
calculateMaxSlotForRow(rows[i]);
902914
}
903915

916+
updateLinkRow(nextRowIdx);
904917
return {x:nx, y:ny};
905918
}
906919

@@ -933,6 +946,7 @@ function moveWordUpARow(w) {
933946
calculateMaxSlotForRow(rows[i]);
934947
}
935948

949+
updateLinkRow(nextRowIdx);
936950
return {x:nx, y:ny};
937951

938952
}

js/render.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,9 +767,10 @@ function drawAllLinkLabels() {
767767
/** redraws all links that have been marked as needsUpdate = true, OR by passing in a boolean of true to indicate that the window has resized **/
768768
function redrawLinks(forceRedrawingAll) { //force redraw of all when resizing window
769769

770+
console.log("inredraw links:" + forceRedrawingAll);
770771
Object.keys(linkObjs).forEach(function(key) {
771772
if (linkObjs[key].needsUpdate || forceRedrawingAll == true) {
772-
////console.log(" link #" + key + " needsUpdate");
773+
console.log(" link #" + key + " needsUpdate");
773774
Config.redraw = 1;
774775
drawLink(linkObjs[key]);
775776
linkObjs[key].needsUpdate = false;
@@ -1079,7 +1080,7 @@ function calculateOnlyRow(rowNum, link, percentagePadding, xPositions, linkStyle
10791080

10801081
function calculateStartRow(idx, rowNum, link, percentagePadding, xPositions, linkStyles ) {
10811082
console.log("in calculateStartRow - " + link.toString());
1082-
1083+
console.log("link height:" + link.h);
10831084
var yPos = rows[rowNum].baseHeight - link.h * percentagePadding;
10841085

10851086
var arrowPos = storeOnlyArrows(rowNum, yPos, link, xPositions);
@@ -1367,7 +1368,7 @@ function drawLink(link) {
13671368

13681369
link.linesLeftX = [];
13691370
link.linesRightX = [];
1370-
1371+
13711372
var minRow = link.rootMinWord.row.idx;
13721373
var maxRow = link.rootMaxWord.row.idx;
13731374

@@ -1413,6 +1414,8 @@ function drawLink(link) {
14131414
calculateMiddleRow(rowNum, i, link, percentagePadding, rowAttachXPos, linkStyles);
14141415
}
14151416
}
1417+
1418+
14161419
}
14171420

14181421

0 commit comments

Comments
 (0)