Skip to content

Commit 2c524bc

Browse files
author
angusforbes
committed
Oops, checked in a bug. Now properly checks if a tag exists or not (in
interact.js and annotate.js's Word class)
1 parent 8d1767e commit 2c524bc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@
135135

136136

137137
// 1. create Words and Links objects (in utils.js) */
138-
var wordObjs = createTestWords(3, 1, 15);
138+
var wordObjs = createTestWords(20, 1, 15);
139139

140140
//var linkObjs = createTestLinks(1,1,0);
141-
var linkObjs = createTestLinks(1,1,1);
141+
var linkObjs = createTestLinks(4,4,4);
142142

143143
// 2. draw words and boxes around words
144144
drawWords(wordObjs);

js/annotate.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,11 @@ class Word {
180180
this.rect = this.rectSVG.bbox();
181181

182182
this.text.x(this.tempX + (this.tempW/2) - (this.text.bbox().w / 2) );
183-
this.tagtext.x(this.tempX + (this.tempW/2) - (this.tagtext.bbox().w / 2) );
184-
183+
184+
if (this.tag != null) {
185+
this.tagtext.x(this.tempX + (this.tempW/2) - (this.tagtext.bbox().w / 2) );
186+
}
187+
185188
this.leftX = this.tempX;
186189
this.rightX = this.tempX + this.tempW;
187190

js/interact.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,11 @@ function moveWordToNewPosition(w, nx, ny) {
770770

771771
//TODO - make these match original position - the Y pos for text is off for tags and words - why isn't the text descent needed here?? ny and w.wy should be (and is!) the same - but the text y pos is a few pixels off!
772772
//Looks like the entire row size jumps one pixel when adding a new row... think this may cause the 1 px differentce
773-
w.tagtext.x(nx + (w.rect.w/2) - (w.tagtext.bbox().w/2) );
774-
w.tagtext.y(ny + textpaddingY/2);// - texts.tagText.descent);
773+
774+
if (w.tag != null) {
775+
w.tagtext.x(nx + (w.rect.w/2) - (w.tagtext.bbox().w/2) );
776+
w.tagtext.y(ny + textpaddingY/2);// - texts.tagText.descent);
777+
}
775778

776779
console.log("ny = " + ny);
777780
console.log("w.wy = " + w.wy);

0 commit comments

Comments
 (0)