Skip to content

Commit b37b44d

Browse files
author
angusforbes
committed
Resizing windows works better
1 parent b142aeb commit b37b44d

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@
146146
// 3. draw each of the links
147147
drawLinks(linkObjs);
148148

149+
150+
changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1);
151+
152+
153+
149154
var prevWidth = svgWidth;
150155
// init objects/listeners...
151156
window.onload = function() {
@@ -157,11 +162,16 @@
157162

158163
svgWidth = (window.innerWidth - 16) * 0.665;
159164

160-
draw.size(svgWidth, draw.height());
165+
changeSizeOfSVGPanel(svgWidth, draw.height());
166+
167+
//draw.size(svgWidth, draw.height());
161168
}
162169
else {
163170
svgWidth = (window.innerWidth - 16)
164-
draw.size(svgWidth, draw.height());
171+
changeSizeOfSVGPanel(svgWidth, draw.height());
172+
173+
174+
// draw.size(svgWidth, draw.height());
165175

166176
}
167177

js/annotate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ function traceBackToWordObj(link, type, word, attach) {
389389
}
390390

391391

392+
//TODO - should there be a global strategy for each class of link types? for the different styles of links? for each parent word/link? or for every single individual link??? E.g., could a work support links with different strategies, or would that become cluttered??
392393
function calcAttachPoints(link, strategy) {
393394

394395
var rootS, rootE;

js/interact.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ function dragRow(x, y, row) {
993993
nextrow.ry = nextrow.rect.y();
994994
nextrow.rh = nextrow.rect.height();
995995

996-
997996
nextrow.lineTop.y(row.rect.bbox().y + row.rect.bbox().h + 5);
998997

999998
for (var i = 0; i < nextrow.words.length; i++) {
@@ -1004,6 +1003,12 @@ function dragRow(x, y, row) {
10041003
//hmm... what about links that pass through the row, but aren't attached to any word on this row?
10051004
updateAllLinks(); //this works for now
10061005

1006+
1007+
//update size of svg window if necessary
1008+
if (row.idx == rows.length - 1) {
1009+
changeSizeOfSVGPanel(window.innerWidth - 16, row.lineBottom.y() + 1)
1010+
}
1011+
10071012
var returnVal = {x:row.dragRect.bbox().x, y:y};
10081013

10091014
return returnVal;

js/render.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,6 @@ function realignWords() {
228228
checkIfCanMoveRight(word.rectSVG.x(), word.rectSVG.width(), word.rectSVG.y(), word, false);
229229
word.update();
230230
}
231-
232-
233-
234231
}
235232

236233
updateWords();
@@ -245,8 +242,20 @@ function removeLastRow() {
245242
rows[rows.length-1].lineBottom.remove();
246243
rows[rows.length-1].dragRect.remove();
247244
rows.pop();
245+
246+
247+
changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1);
248+
248249
}
249250

251+
function changeSizeOfSVGPanel(w, h) {
252+
253+
svgWidth = w;
254+
svgHeight = h;
255+
draw.size(w, h);
256+
}
257+
258+
250259
function appendRow() {
251260

252261
row = new Row(rows.length);
@@ -265,6 +274,8 @@ function appendRow() {
265274

266275
drawRow(row);
267276

277+
changeSizeOfSVGPanel(window.innerWidth - 16, row.lineBottom.y() + 1);
278+
268279
}
269280

270281
function drawRow(row) {

0 commit comments

Comments
 (0)