Skip to content

Commit

Permalink
fix: If stack changes while isPlaying, stopClip and then playClip aft…
Browse files Browse the repository at this point in the history
…er first image load (#72)

Co-authored-by: kedar.netelixir <[email protected]>
  • Loading branch information
ckedar and kedar.netelixir authored Mar 23, 2020
1 parent cba8955 commit b84c171
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/CornerstoneViewport/CornerstoneViewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit b84c171

Please sign in to comment.