Skip to content

Commit 0085daf

Browse files
wilsonGenarpanda
authored andcommitted
fix ROI shift issue when saving svg (igvteam#1742)
* fix ROI shift issue when saving svg * cleaner solution suggested by Turner
1 parent 6f56315 commit 0085daf

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

js/browser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class Browser {
380380
*/
381381
toSVG() {
382382

383-
const {y, width, height} = this.columnContainer.getBoundingClientRect()
383+
const {x, y, width, height} = this.columnContainer.getBoundingClientRect()
384384

385385
const h_render = 8000
386386

@@ -412,6 +412,8 @@ class Browser {
412412
trackView.renderSVGContext(context, delta)
413413
}
414414

415+
// ROI -> SVG
416+
delta.deltaX = x
415417
this.roiManager.renderSVGContext(context, delta)
416418

417419
// reset height to trim away unneeded svg canvas real estate. Yes, a bit of a hack.

js/roi/ROIManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ class ROIManager {
237237
// body
238238
const { x, y, width, height } = regionElement.getBoundingClientRect()
239239
context.fillStyle = regionElement.style.backgroundColor
240-
context.fillRect(x+deltaX, y+deltaY, width, height)
240+
context.fillRect(x-deltaX, y+deltaY, width, height)
241241

242242
// header
243243
const header = regionElement.querySelector('div')
244244
const { x:xx, y:yy, width:ww, height:hh } = header.getBoundingClientRect()
245245
context.fillStyle = header.style.backgroundColor
246-
context.fillRect(xx+deltaX, yy+deltaY, ww, hh)
246+
context.fillRect(xx-deltaX, yy+deltaY, ww, hh)
247247
}
248248
}
249249

0 commit comments

Comments
 (0)