src/hg/js/hgTracks.js 1.19
1.19 2009/02/24 22:47:21 larrym
fix bug in updatePosition that caused negative chrom positions when user was at/near beginning of the the chrom
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.18
retrieving revision 1.19
diff -b -B -U 4 -r1.18 -r1.19
--- src/hg/js/hgTracks.js 21 Jan 2009 00:12:40 -0000 1.18
+++ src/hg/js/hgTracks.js 24 Feb 2009 22:47:21 -0000 1.19
@@ -91,9 +91,15 @@
startDelta = Math.floor(mult * (x1 - insideX));
}
if(singleClick) {
var newStart = (winStart + 1) + (startDelta - Math.floor(newWinWidth / 2));
- var newEnd = (winStart + 1) + (startDelta + Math.floor(newWinWidth / 2));
+ if(newStart < 1) {
+ newStart = 1;
+ newEnd = newWinWidth;
+ } else {
+ // hgTracks gracefully handles overflow past the end of the chrom, so don't worry about that.
+ newEnd = (winStart + 1) + (startDelta + Math.floor(newWinWidth / 2));
+ }
newPos = chromName + ":" + newStart + "-" + newEnd;
newSize = newEnd - newStart + 1;
} else {
var endDelta;