Skip to content

Commit 562813e

Browse files
committed
fix toggle issue
1 parent c7e9c06 commit 562813e

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

css/style.css

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,15 @@ button {
4040
.node { cursor: pointer; }
4141

4242
#graph {
43-
width:100%;
44-
height:220px;
45-
border-top: 1px solid #ccc;
46-
background:#fff;
47-
position:fixed;
48-
bottom:0;
49-
left:0;
50-
overflow:hidden;
43+
cursor:move;
44+
width:100%;
45+
height:220px;
46+
border-top: 1px solid #ccc;
47+
background:#fff;
48+
position:fixed;
49+
bottom:0;
50+
left:0;
51+
overflow:hidden;
5152
}
5253

5354

js/GraphLayout.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ class GraphLayout {
6565
this.links.selectAll('*').remove();
6666
}
6767
graph(words) {
68-
if (words.length === 0 || this.words.length === words.length &&
69-
this.words.every((w,i) => words.indexOf(w) > -1)) { return; }
70-
else { this.words = words; }
68+
this.words = words;
7169

7270
const maxDepth = this.maxDepth;
7371
let localMaxDepth = 0;
@@ -222,7 +220,9 @@ class GraphLayout {
222220
unhoverNode(d);
223221
let newArray = this.words.slice();
224222
let word = newArray.splice(i, 1, d.node)[0];
225-
word.toggleHighlight(false);
223+
if (newArray.indexOf(word) < 0) {
224+
word.toggleHighlight(false);
225+
}
226226
d.node.toggleHighlight(true);
227227
this.graph(newArray);
228228
}

js/annotate.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ class Link {
116116
this.isSelected = select;
117117
}
118118

119-
this.labelRectSVGs.forEach(rect => rect.toggleClass('selected', this.isSelected));
119+
if (this.isSelected) {
120+
this.labelRectSVGs.forEach(rect => rect.addClass('selected'));
121+
}
122+
else {
123+
this.labelRectSVGs.forEach(rect => rect.removeClass('selected'));
124+
}
120125
}
121126

122127
hover(label) {
@@ -300,7 +305,12 @@ class Word {
300305
this.isSelected = select;
301306
}
302307

303-
this.svg.toggleClass('selected', this.isSelected);
308+
if (this.isSelected) {
309+
this.svg.addClass('selected');
310+
}
311+
else {
312+
this.svg.removeClass('selected');
313+
}
304314
}
305315

306316
hover() {

libs/d3.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)