From b84c1714d0b5a639166e87c91fd9c6b3ee2d95e8 Mon Sep 17 00:00:00 2001 From: Kedar Date: Tue, 24 Mar 2020 00:23:12 +0530 Subject: [PATCH] fix: If stack changes while isPlaying, stopClip and then playClip after first image load (#72) Co-authored-by: kedar.netelixir --- src/CornerstoneViewport/CornerstoneViewport.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CornerstoneViewport/CornerstoneViewport.js b/src/CornerstoneViewport/CornerstoneViewport.js index d107461..062c8e8 100644 --- a/src/CornerstoneViewport/CornerstoneViewport.js +++ b/src/CornerstoneViewport/CornerstoneViewport.js @@ -229,6 +229,7 @@ class CornerstoneViewport extends Component { try { // load + display image const imageId = stack[imageIndex]; + cornerstoneTools.stopClip(this.element); const image = await cornerstone.loadAndCacheImage(imageId); cornerstone.displayImage(this.element, image); @@ -270,7 +271,9 @@ class CornerstoneViewport extends Component { isOverlayVisible: prevIsOverlayVisible, } = prevProps; const validFrameRate = Math.max(frameRate, 1); - const shouldStart = isPlaying !== prevIsPlaying && isPlaying; + const shouldStart = + (isPlaying !== prevIsPlaying && isPlaying) || + (isPlaying && hasStackChanged); const shouldPause = isPlaying !== prevIsPlaying && !isPlaying; const hasFrameRateChanged = isPlaying && frameRate !== prevFrameRate;