Skip to content

Commit

Permalink
Toggle only ROI background. Leave header intact
Browse files Browse the repository at this point in the history
  • Loading branch information
turner committed Feb 7, 2024
1 parent 506ef26 commit add838b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions js/roi/ROIManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class ROIManager {
regionElement.style.left = `${pixelX}px`
regionElement.style.width = `${pixelWidth}px`
regionElement.style.backgroundColor = roiSet.color
regionElement.dataset.color = roiSet.color
regionElement.dataset.region = regionKey

const header = DOMUtils.div()
Expand Down
23 changes: 21 additions & 2 deletions js/roi/ROITable.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ class ROITable extends RegionTableBase {
setROIVisibility(isVisible) {

const elements = this.browser.columnContainer.querySelectorAll('.igv-roi-region')
for (const el of elements) {
el.style.display = false === isVisible ? 'none' : 'flex'

for (let i = 0; i < elements.length; i++) {
const el = elements[ i ]
false === isVisible ? updateElementAlpha(el, 0.0) : el.style.backgroundColor = el.dataset.color

}

this.toggleROIButton.textContent = false === isVisible ? 'Show all ROIs' : 'Hide all ROIs'
Expand Down Expand Up @@ -153,4 +156,20 @@ class ROITable extends RegionTableBase {
}

}

function updateElementAlpha(element, alpha) {

const rgba = window.getComputedStyle(element).backgroundColor;

const rgbaArray = rgba.match(/[\d.]+/g);

if (rgbaArray.length === 3) {
rgbaArray.push(1)
}

rgbaArray[3] = alpha;

element.style.backgroundColor = `rgba(${rgbaArray.join(', ')})`
}

export default ROITable

0 comments on commit add838b

Please sign in to comment.