Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions rptools/rpviz/templates/css/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,37 @@ body {
box-shadow: 0 0 5px 0px black;
}

/* Hide panels **************************************/
#toggle-panels-container {
position: fixed;
top: 10px;
left: 50%;
transform: translateX(-50%);
z-index: 9999;
}

#toggle-panels {
padding: 6px 12px;
font-size: 13px;
cursor: pointer;
}

/* Hide panels */
.panel-hidden {
display: none !important;
}

/* Expanded view when panels are hidden */
#viewer.panels-hidden #cy {
width: 100%;
margin-left: 0;
}

#viewer.panels-hidden #interaction,
#viewer.panels-hidden #info {
display: none !important;
}

/* Left panel: pathway level interaction **************************************/
#interaction {
position: absolute;
Expand Down
48 changes: 48 additions & 0 deletions rptools/rpviz/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,55 @@
<!-- <script src="js/cytoscape-cola-1.4.3.js"></script>-->

</head>

<!-- Controls for hiding panels -->
<script>
$(function () {

$('#toggle-panels').on('click', function () {
if (!window.cy) return;

const cyEl = document.getElementById('cy');

const oldPan = cy.pan();
const oldZoom = cy.zoom();
const oldLeft = cyEl.getBoundingClientRect().left;

$('#interaction, #info').toggleClass('panel-hidden');
$('#viewer').toggleClass('panels-hidden');

requestAnimationFrame(() => {
const newLeft = cyEl.getBoundingClientRect().left;

// Correct sign: compensate by how much the container shifted
const shift = oldLeft - newLeft;

cy.resize();
cy.zoom(oldZoom);
cy.pan({ x: oldPan.x + shift, y: oldPan.y });
});
});

function resizeCy() {
if (!window.cy) return;

// save current viewport
const z = cy.zoom();
const p = cy.pan();

cy.resize(); // let Cytoscape recompute its canvas size
cy.zoom(z); // restore zoom
cy.pan(p); // restore pan
// (no cy.fit())
}

});
</script>

<body>
<div id="toggle-panels-container">
<button id="toggle-panels">Toggle panels</button>
</div>

<div id="base">

Expand Down
Loading