Skip to content

Commit 7d04430

Browse files
committed
fix a few global vars
1 parent 4b78561 commit 7d04430

File tree

3 files changed

+17
-32
lines changed

3 files changed

+17
-32
lines changed

index.html

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
Config.wordHeight = texts.wordText.maxHeight + (Config.textPaddingY * 2);
107107
Config.minWordWidth = Math.max( getTextWidthAndHeight("i", texts.wordText.style).w + (Config.handleW * 2), getTextWidthAndHeight("i", texts.tagText.style).w + (Config.handleW * 2) );
108108

109-
109+
var rowOffsetX = 0;
110110
var rowOffsetWord = null;
111111
var prevX = -1;
112112

@@ -130,31 +130,17 @@
130130
var prevWidth = Config.svgWidth;
131131

132132
function svgResize() {
133-
var w, widthPercChange;
133+
var widthPercChange;
134134
if (Panel.isOpen) {
135-
136-
svgWidth = (window.innerWidth - 16) * 0.665;
137-
138-
changeSizeOfSVGPanel(svgWidth, draw.height());
139-
140-
//draw.size(svgWidth, draw.height());
135+
Config.svgWidth = (window.innerWidth - 16) * 0.665;
141136
}
142137
else {
143-
svgWidth = (window.innerWidth - 16)
144-
changeSizeOfSVGPanel(svgWidth, draw.height());
145-
146-
147-
// draw.size(svgWidth, draw.height());
148-
138+
Config.svgWidth = (window.innerWidth - 16)
149139
}
150-
151-
widthPercChange = svgWidth / prevWidth;
152-
prevWidth = svgWidth;
153-
//console.log("\nwidthPercChange = " + widthPercChange);
154-
155-
156-
recalculateRows(widthPercChange); //makes sure that the words fit in the current width, else makes new rows
157-
140+
changeSizeOfSVGPanel(Config.svgWidth, draw.height());
141+
widthPercChange = Config.svgWidth / prevWidth;
142+
prevWidth = Config.svgWidth;
143+
recalculateRows(widthPercChange); //makes sure that the words fit in the current width, else makes new rows
158144
}
159145

160146
document.addEventListener('keydown',

js/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const Config = {
2626
oddRowsColor_selected: '#bbbbff',
2727
dragRectSide: 8,
2828
dragRectMargin: 1,
29-
rowOffsetX: 0,
3029
dragDir: 0,
3130
linkStrokeThickness: 1.5,
3231
linkStrokeColor: '#cc9999',

js/interact.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function addDragStartingAndEndingListeners(elem) {
254254
mout(rowOffsetWord);
255255
}
256256

257-
Config.rowOffsetX = 0;
257+
rowOffsetX = 0;
258258
rowOffsetWord = null;
259259

260260
prevX = -1;
@@ -470,9 +470,9 @@ function dragLeftHandle(x, y, word) {
470470
var dragDir = checkDragDirection(x);
471471

472472
if (dragDir == directions.BACKWARD) {
473-
return checkIfCanDragLeftHandleLeft(x + Config.rowOffsetX, y, word);
473+
return checkIfCanDragLeftHandleLeft(x + rowOffsetX, y, word);
474474
} else if (dragDir == directions.FORWARD) {
475-
return checkIfCanDragLeftHandleRight(x + Config.rowOffsetX, y, word);
475+
return checkIfCanDragLeftHandleRight(x + rowOffsetX, y, word);
476476
} else {
477477
return {x:word.leftHandle.bbox().x, y:word.leftHandle.bbox().y};
478478
}
@@ -509,9 +509,9 @@ function dragRightHandle(x, y, word) {
509509
var dragDir = checkDragDirection(x);
510510

511511
if (dragDir == directions.BACKWARD) {
512-
return checkIfCanDragRightHandleLeft(x + Config.rowOffsetX, y, word);
512+
return checkIfCanDragRightHandleLeft(x + rowOffsetX, y, word);
513513
} else if (dragDir == directions.FORWARD) {
514-
return checkIfCanDragRightHandleRight(x + Config.rowOffsetX, y, word);
514+
return checkIfCanDragRightHandleRight(x + rowOffsetX, y, word);
515515
} else {
516516
return {x:word.rightHandle.bbox().x, y:word.rightHandle.bbox().y};
517517
}
@@ -611,7 +611,7 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) {
611611

612612
//handle drag offset if i am dragging this word
613613
if (word == rowOffsetWord) {
614-
Config.rowOffsetX -= (Config.svgWidth - (2*Config.edgePadding) - (w) );
614+
rowOffsetX -= (Config.svgWidth - (2*Config.edgePadding) - (w) );
615615
}
616616

617617
rx = vals.x;
@@ -685,7 +685,7 @@ function checkIfCanMoveLeft(x, w, y, word, adjustWidth) {
685685

686686
//handle drag offset if i am dragging this word
687687
if (word == rowOffsetWord) {
688-
Config.rowOffsetX += (Config.svgWidth - (2*Config.edgePadding) - (w) );
688+
rowOffsetX += (Config.svgWidth - (2*Config.edgePadding) - (w) );
689689
}
690690

691691
rx = Config.svgWidth - Config.edgePadding - w;
@@ -814,9 +814,9 @@ function dragWord(x, y, word) {
814814
var dragDir = checkDragDirection(x);
815815

816816
if (dragDir == directions.BACKWARD) {
817-
return checkIfCanMoveLeft(x + Config.rowOffsetX, word.aboveRect.bbox().width, y, word, false);
817+
return checkIfCanMoveLeft(x + rowOffsetX, word.aboveRect.bbox().width, y, word, false);
818818
} else if (dragDir == directions.FORWARD) {
819-
return checkIfCanMoveRight(x + Config.rowOffsetX, word.aboveRect.bbox().width, y, word, false);
819+
return checkIfCanMoveRight(x + rowOffsetX, word.aboveRect.bbox().width, y, word, false);
820820
} else {
821821
return {x:word.aboveRect.bbox().x, y:word.aboveRect.bbox().y};
822822
}

0 commit comments

Comments
 (0)