feat(resize): Optimize resizing process and maintain zoom level (#3889)

This commit is contained in:
Alireza authored and GitHub committed 2024-02-21 13:49:23 -05:00
1 parent a2a0090eeb
commit b3a0faf5f5
37 files changed
+1395 -968

No files matched your search

+22 -7
View File
@@ -1,4 +1,5 @@
import React, { useEffect, useCallback } from 'react';
import React, { useEffect, useCallback, useRef } from 'react';
import ReactResizeDetector from 'react-resize-detector';
import PropTypes from 'prop-types';
import { ServicesManager, Types, MeasurementService } from '@ohif/core';
import { ViewportGrid, ViewportPane, useViewportGrid } from '@ohif/ui';
@@ -13,6 +14,7 @@ function ViewerViewportGrid(props) {
const { layout, activeViewportId, viewports } = viewportGrid;
const { numCols, numRows } = layout;
const elementRef = useRef(null);
// TODO -> Need some way of selecting which displaySets hit the viewports.
const { displaySetService, measurementService, hangingProtocolService, uiNotificationService } = (
@@ -342,13 +344,26 @@ function ViewerViewportGrid(props) {
}
return (
<ViewportGrid
numRows={numRows}
numCols={numCols}
<div
ref={elementRef}
className="h-full w-full"
>
{/* {ViewportPanes} */}
{getViewportPanes()}
</ViewportGrid>
<ViewportGrid
numRows={numRows}
numCols={numCols}
>
<ReactResizeDetector
refreshMode="debounce"
refreshRate={7} // ms seems to be fine for 10 viewports
onResize={() => {
viewportGridService.setViewportGridSizeChanged();
}}
targetRef={elementRef.current}
/>
{/* {ViewportPanes} */}
{getViewportPanes()}
</ViewportGrid>
</div>
);
}