[Bug] StackViewport.setImageIdIndex should set this.targetImageIdIndex too
Describe the Bug
Calling StackViewport.setImageIdIndex on a stack viewport does update this.currentImageIdIndex, but does not update this.targetImageIdIndex. StackViewport.scroll, on the other hand, using this.targetImageIdIndex as a base. As a result, if you scroll with the scroll tool to eg. image 10, then call setImageIdIndex(1), and then use the scroll tool again, the viewport will not scroll to image 2, but to image 11.
Steps to Reproduce
- Create a stack viewport
- Use the mouse scroll tool to scroll to a given image
- Call
setImageIdIndexon a different image - Scroll again
The current behavior
Scroll continues from the last image scrolled, instead of continuing from the image set using setImageIdIndex
The expected behavior
Scroll should be continuous even if setImageIdIndex is called.
OS
Linux
Node version
20
Browser
Firefox 128
I added the following hack for now, which fixes the issue:
viewport.setImageIdIndex(imageIndex); // will update this.currentImageIdIndex but not this.targetImageIdIndex
(viewport as unknown as {targetImageIdIndex: number}).targetImageIdIndex = imageIndex; // workaround for #1393
I have the same issue
Can you check the latest OHIF viewer, which now includes Cornerstone 3D 2.0?
Here are the migration guides:
Try OHIF locally: https://viewer-dev.ohif.org/localbasic
Try Cornerstone3D 2.0 locally: https://www.cornerstonejs.org/live-examples/local.html
I ran into this bug today and fixed it. Sorry if I didn't understand the issue at first.