Skip to content

Commit

Permalink
Repair rulerViewport.js. Test browser.setCustomCursorGuideMouseHandler()
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Jul 25, 2024
1 parent fae1b22 commit d89acfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dev/api/getUserDefinedROIs.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h3>User defined ROIs:</h3>

const div = document.getElementById("user-defined-rois")
div.innerHTML = ""

const list = document.createElement("ul")
div.appendChild(list)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<script type="module">

import igv from "../../js/index.js";
import {StringUtils} from "../node_modules/igv-utils/src/index.js";
import {StringUtils} from "../../node_modules/igv-utils/src/index.js";

const numberFormatter = StringUtils.numberFormatter;

let browser;
Expand All @@ -30,8 +31,8 @@
const options =
{
genome: "hg19",
locus: [ 'egfr', 'myc' ],
// locus: "myc",
// locus: [ 'egfr', 'myc' ],
locus: "myc",
showAllChromosomes: true,
showCursorTrackingGuide: true,
tracks:
Expand All @@ -47,8 +48,8 @@

browser = await igv.createBrowser(document.getElementById('igvDiv'), options);

browser.setCustomCursorGuideMouseHandler(({bp, start, end, interpolant}) => {
console.log(`startBP ${ numberFormatter(start) } bp ${ numberFormatter(bp) } interpolant ${ interpolant.toFixed(3) } `);
browser.setCustomCursorGuideMouseHandler(({bp, interpolant}) => {
console.log(`base-pair ${ numberFormatter(bp) } interpolant ${ interpolant.toFixed(3) } `);
});

})();
Expand Down
5 changes: 3 additions & 2 deletions js/rulerViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ class RulerViewport extends TrackViewport {

if (isWholeGenome) {
this.$tooltip.hide()
return
return undefined
}

const {x} = DOMUtils.translateMouseCoordinates(event, this.$viewport.get(0))
const {start, bpPerPixel} = this.referenceFrame
const {start, end, bpPerPixel} = this.referenceFrame
const bp = Math.round(0.5 + start + Math.max(0, x) * bpPerPixel)

this.$tooltipContent.text(StringUtils.numberFormatter(bp))
Expand All @@ -187,6 +187,7 @@ class RulerViewport extends TrackViewport {
if (this.$tooltip) this.$tooltip.hide()
}, toolTipTimeout)

return { start, bp, end }
}

}
Expand Down

0 comments on commit d89acfd

Please sign in to comment.