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

Scroll speed increase #30

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ processor/application_default_credentials.json
processor/.env
processor/helpers/__pycache__/
processor/.DS_Store
application_default_credentials.json
server/.env
client/yarn.lock
processor/samples/
14 changes: 10 additions & 4 deletions client/src/components/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const {primaryActiveColor, headerBorderColor, headerBg, headerButtonColor, heade

const StackHelper = AMI.stackHelperFactory(THREE);

const DELTA_SLICE_BUTTON = 1 ;
const DELTA_SLICE_MOUSE = 5;


export const Viewer = (props) => {

Expand Down Expand Up @@ -97,12 +100,15 @@ export const Viewer = (props) => {
const handleScroll = (event) => {
const direction = event.deltaY < 0 ? DIRECTIONS.DOWN : DIRECTIONS.UP;
const currentAtlas = currentAtlasStackHelperRef.current;
handleScrollHelper(currentAtlas, direction, DELTA_SLICE_MOUSE);
};

const newIndex = getNewSliceIndex(currentAtlas, direction);
const handleScrollHelper = (atlas, direction, delta) => {
const newIndex = getNewSliceIndex(atlas, direction, delta);
if (newIndex !== null) {
setSliceIndex(newIndex);
}
};
}


const updateAllStackHelpersIndex = (newIndex) => {
Expand All @@ -117,14 +123,14 @@ export const Viewer = (props) => {

const handlePreviousSlice = () => {
if (sliceIndex && sliceIndex > 0) {
setSliceIndex(sliceIndex - 1);
handleScrollHelper(currentAtlasStackHelperRef.current, DIRECTIONS.DOWN, DELTA_SLICE_BUTTON);
}
};

const handleNextSlice = () => {
const currentAtlas = currentAtlasStackHelperRef.current;
if (sliceIndex && currentAtlas && sliceIndex < currentAtlas.orientationMaxIndex - 1) {
setSliceIndex(sliceIndex + 1)
handleScrollHelper(currentAtlasStackHelperRef.current, DIRECTIONS.UP, DELTA_SLICE_BUTTON);
}
};

Expand Down
6 changes: 3 additions & 3 deletions client/src/helpers/stackHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ function isVector3Object(obj) {
return obj && typeof obj === 'object' && 'x' in obj && 'y' in obj && 'z' in obj;
}

export const getNewSliceIndex = (stackHelper, direction) => {
export const getNewSliceIndex = (stackHelper, direction, delta = 1) => {
if (!stackHelper) {
return null;
}

if (direction === DIRECTIONS.UP && stackHelper.index < stackHelper.orientationMaxIndex - 1) {
return stackHelper.index + 1;
return stackHelper.index + delta;
} else if (direction === DIRECTIONS.DOWN && stackHelper.index > 0) {
return stackHelper.index - 1;
return stackHelper.index - delta;
}

return null;
Expand Down