Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom scroll index now taken from store #413

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions imaging/tools/custom/customMouseWheelScrollTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
slicesnumber: number;
is4D: boolean;
isMultiframe: boolean;
nextIndex: number | null;
/*
* @constructs CustomMouseWheelScrollTool
* @param {object} props - Any properties passed to the component
Expand All @@ -73,7 +72,6 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
};

super(props, defaultProps);
this.nextIndex = null;
this.currentMode = "stack";
this.framesNumber = this.configuration.framesNumber;
this.slicesnumber = 0;
Expand Down Expand Up @@ -212,10 +210,7 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
// Handle 'stack' mode

// Calculate validIndex for 'stack' mode (no looping) between 0 and (N-1)*framesnumber where N=numberofslices=numberofimageids/numberofframes
let lastIndex =
this.nextIndex != null
? this.nextIndex
: store.get(["viewports", element.id, "sliceId"]);
let lastIndex = store.get(["viewports", element.id, "sliceId"]);
let nextIndex = lastIndex + direction;

if (lastIndex === -1) {
Expand All @@ -228,7 +223,6 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
nextIndex >= 0 && nextIndex < imageIds.length && this.slicesnumber > 0
? nextIndex
: lastIndex;
this.nextIndex = validIndex;
// Scroll to the calculated index
scrollToIndex(element, validIndex);
if (getActiveLayer(element.id)) {
Expand All @@ -244,9 +238,7 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
// Handle 'slice' mode
let lastIndex =
this.isMultiframe === true || this.is4D === true
? this.nextIndex != null
? this.nextIndex
: store.get(["viewports", element.id, "sliceId"])
? store.get(["viewports", element.id, "sliceId"])
: stackData.currentImageIdIndex;

this.slicesnumber = Math.ceil(imageIds.length / this.framesNumber) - 1;
Expand All @@ -270,7 +262,6 @@ export default class CustomMouseWheelScrollTool extends BaseTool {
) {
nextIndex = startFrame;
}
this.nextIndex = nextIndex;
// Scroll to the calculated index
scrollToIndex(element, nextIndex);

Expand Down
Loading