Skip to content

Commit

Permalink
feat(viewer): add process conditional statements using isLegacyViewport
Browse files Browse the repository at this point in the history
  • Loading branch information
LTakhyunKim committed Dec 1, 2022
1 parent c097c3e commit 7cc19d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions libs/insight-viewer/src/hooks/useImageDisplay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ const useImageDisplay: UseImageDisplay = ({ element, image, viewportRef, onViewp
resetViewportRef.current = viewportRef.current._initialViewport
}

// Updates the viewport prop of Viewer.
if (onViewportChange) {
/**
* Updates the viewport prop of Viewer.
* TODO: Need to delete this logic when removing legacy useViewport
*/
if (onViewportChange && viewportRef.current['isLegacyViewport']) {
onViewportChange({
...formatViewerViewport(viewport),
_viewportOptions: viewportRef.current._viewportOptions ?? DEFAULT_VIEWPORT_OPTIONS,
isLegacyViewport: true,
})
}
}, [image, element, viewportRef, onViewportChange])
Expand Down
2 changes: 1 addition & 1 deletion libs/insight-viewer/src/hooks/useViewportUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function useViewportUpdate({ element, image, viewport: newViewpor

setViewport(<HTMLDivElement>element, formatCornerstoneViewport(viewport, elementUpdatedViewport))

if (onViewportChange) {
if (onViewportChange && newViewportProp.isLegacyViewport) {
// When resetting, update Viewer's viewport prop
if (willReset) {
onViewportChange({
Expand Down

0 comments on commit 7cc19d5

Please sign in to comment.