You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was able to deal with this issue by writing the following function:
function saveViewport() {
const el = document.getElementById('image-element');
viewport.current = cornerstone.getViewport(el);
translation.current = {
x: viewport.current.translation.x,
y: viewport.current.translation.y
}
}
In response to an event such as a button click or slider change, I call this function to preserve the viewport in a reference variable. When the view is redrawn my useEffect function is called and I restore the viewport.
Notice that I copy the translation object explicitly. This is because assignment of objects in JavaScript is by reference and not value. The value attributes of the viewport are preserved when I assign the viewport to my reference variable but not the object attributes. If I don't do this, then the translation values are reset to 0.
Prerequisites
Description
Steps to Reproduce the issue
Expected behavior: I expect the image to retain its size as a result of zooming.
Actual behavior: (What actually happened)
CodeSandbox With Reproduction of Issue: I'll have to work on this. Need to setup a React app to reproduce the issue.
The text was updated successfully, but these errors were encountered: