c80f2162ba521e6361b433497a17c67bd83d4ef7 max Tue Aug 29 14:02:08 2017 -0700 fixing highlight-off bug that must have been in the code forever, refs #20046 diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 43c3ab3..37c54cb 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -366,30 +366,38 @@ imgOfs.left + imgWidth + slop; return ( (selection.event.pageX >= leftX) && (selection.event.pageX < rightX) && (selection.event.pageY >= (imgOfs.top - slop)) && (selection.event.pageY < (imgOfs.top + imgHeight + slop))); }, pixelsToBases: function (img, selStart, selEnd, winStart, winEnd) { // Convert image coordinates to chromosome coordinates var imgWidth = jQuery(img).width() - hgTracks.insideX; var width = hgTracks.winEnd - hgTracks.winStart; var mult = width / imgWidth; // mult is bp/pixel multiplier var startDelta; // startDelta is how many bp's to the right/left var x1; + + // The magic number three appear at another place in the code + // as LEFTADD. It was originally annotated as "borders or cgi item calc + // ?" by Larry. It has to be used when going any time when converting + // between pixels and coordinates. + selStart -= 3; + selEnd -= 3; + if (hgTracks.revCmplDisp) { x1 = Math.min(imgWidth, selStart); startDelta = Math.floor(mult * (imgWidth - x1)); } else { x1 = Math.max(hgTracks.insideX, selStart); startDelta = Math.floor(mult * (x1 - hgTracks.insideX)); } var endDelta; var x2; if (hgTracks.revCmplDisp) { endDelta = startDelta; x2 = Math.min(imgWidth, selEnd); startDelta = Math.floor(mult * (imgWidth - x2)); } else { x2 = Math.max(hgTracks.insideX, selEnd);