fix(modes): don't attempt to retrieve a stage index if HPs (#4552)

Co-authored-by: Ibrahim <93064150+IbrahimCSAE@users.noreply.github.com>
Co-authored-by: Ștefan Silviu-Alexandru <silviu.stefan@atta.systems>
This commit is contained in:
authored and GitHub committed 2024-12-03 09:14:41 -05:00
1 parent 71f06dcd3e
commit e5286d9fc2
12 files changed
+43 -48

No files matched your search

@@ -130,6 +130,21 @@ class CornerstoneViewportService extends PubSubService implements IViewportServi
* individual resize observers
*/
public resize(isGridResize = false) {
// https://stackoverflow.com/a/26279685
// This resize() call, among other things, rerenders the viewports. But when the entire viewer is
// display: none'd, it makes the size of all hidden elements 0, including the viewport canvas and its containers.
// Even if the viewer is later displayed again, trying to render when the size is 0 permanently "breaks" the
// viewport, making it fully black even after the size is normal again. So just ignore resize events when hidden:
const areViewportsHidden = Array.from(this.viewportsById.values()).every(viewportInfo => {
const element = viewportInfo.getElement();
return element.clientWidth === 0 && element.clientHeight === 0;
});
if (areViewportsHidden) {
console.warn('Ignoring resize when viewports have size 0');
return;
}
// if there is a grid resize happening, it means the viewport grid
// has been manipulated (e.g., panels closed, added, etc.) and we need
// to resize all viewports, so we will add a timeout here to make sure