Skip to content

Commit fd12537

Browse files
committed
TrackViewport edits
1 parent 9ec13ae commit fd12537

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

js/trackViewport.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TrackViewport extends Viewport {
3737

3838
const track = this.trackView.track;
3939
if ('sequence' !== track.type) {
40-
this.zoomInNoticeElement = this.createZoomInNotice(this.viewportElement);
40+
this.zoomInNoticeElement = TrackViewport.createZoomInNotice(this.viewportElement);
4141
}
4242

4343
if ("sequence" !== track.id) {
@@ -74,7 +74,9 @@ class TrackViewport extends Viewport {
7474
}
7575

7676
startSpinner() {
77-
this.spinnerElement.style.display = 'block';
77+
if (this.spinnerElement){
78+
this.spinnerElement.style.display = 'flex';
79+
}
7880
}
7981

8082
stopSpinner() {
@@ -129,7 +131,7 @@ class TrackViewport extends Viewport {
129131
this.setContentHeight(minHeight)
130132
}
131133
if (this.zoomInNoticeElement) {
132-
this.zoomInNoticeElement.style.display = 'block';
134+
this.zoomInNoticeElement.style.display = 'flex';
133135
}
134136
return false
135137
} else {
@@ -240,7 +242,7 @@ class TrackViewport extends Viewport {
240242
}
241243
this.loading = {start: bpStart, end: bpEnd}
242244
this.startSpinner()
243-
245+
244246
const track = this.trackView.track
245247
const features = await this.getFeatures(track, chr, bpStart, bpEnd, referenceFrame.bpPerPixel)
246248
if (features) {
@@ -421,13 +423,14 @@ class TrackViewport extends Viewport {
421423

422424
if (!this.canvas) return
423425

426+
const w = this.viewportElement.clientWidth * window.devicePixelRatio;
427+
const h = this.viewportElement.clientHeight * window.devicePixelRatio;
428+
429+
const x = -this.canvas.offsetLeft * window.devicePixelRatio
430+
424431
const canvasMetadata = this.canvas._data
425432
const canvasTop = canvasMetadata ? canvasMetadata.pixelTop : 0
426-
const devicePixelRatio = window.devicePixelRatio
427-
const w = this.viewportElement.clientWidth * devicePixelRatio;
428-
const h = this.viewportElement.clientHeight * devicePixelRatio;
429-
const x = -this.canvas.getBoundingClientRect().left * devicePixelRatio;
430-
const y = (-this.contentTop - canvasTop) * devicePixelRatio;
433+
const y = (-this.contentTop - canvasTop) * window.devicePixelRatio;
431434

432435
const ctx = this.canvas.getContext("2d")
433436
const imageData = ctx.getImageData(x, y, w, h)
@@ -494,7 +497,7 @@ class TrackViewport extends Viewport {
494497

495498
renderSVGContext(context, {deltaX, deltaY}, includeLabel = true) {
496499

497-
const zoomInNotice = this.zoomInNoticeElement && this.zoomInNoticeElement.is(":visible")
500+
const zoomInNotice = this.zoomInNoticeElement && this.zoomInNoticeElement.style.display !== 'flex'
498501

499502
if (!zoomInNotice) {
500503

@@ -617,20 +620,19 @@ class TrackViewport extends Viewport {
617620
return (!this.featureCache.containsRange(chr, bpStart, bpEnd, bpPerPixel, this.windowFunction))
618621
}
619622

620-
createZoomInNotice(parentElement) {
623+
static createZoomInNotice(parentElement) {
621624

622-
const element = document.createElement('div');
623-
element.className = 'igv-zoom-in-notice-container';
624-
parentElement.appendChild(element);
625-
626-
const $e = document.createElement('div');
627-
element.appendChild($e);
625+
const container = document.createElement('div');
626+
container.className = 'igv-zoom-in-notice-container';
627+
parentElement.appendChild(container);
628628

629-
$e.textContent = 'Zoom in to see features';
629+
const element = document.createElement('div');
630+
container.appendChild(element);
631+
element.textContent = 'Zoom in to see features';
630632

631-
element.style.display = 'none';
633+
container.style.display = 'none';
632634

633-
return element;
635+
return container;
634636
}
635637

636638
viewIsReady() {

0 commit comments

Comments
 (0)