Skip to content

Commit

Permalink
feat: set zoom in/out as the default behavior with Shift + scroll (#2975
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hamed-musallam committed Mar 21, 2024
1 parent 2ed8018 commit b5d28f6
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/component/reducer/actions/ToolsActions.ts
Expand Up @@ -401,19 +401,20 @@ function handleZoom(draft: Draft<State>, action: ZoomAction) {
toolOptions: { selectedTool },
} = draft;
const scaleRatio = toScaleRatio(options);
const { altKey, shiftKey } = options;

switch (displayerMode) {
case '2D': {
const { shiftKey } = options;

if (trackID === 'CENTER_2D') {
// change the vertical scale for traces in 2D phase correction
if (selectedTool === 'phaseCorrectionTwoDimensions') {
const { activeTraces } = getTwoDimensionPhaseCorrectionOptions(draft);
activeTraces.scaleRatio *= scaleRatio;
return;
}

//zoom in/out in 2d
if (selectedTool === 'zoom' && shiftKey) {
if (shiftKey) {
zoomWithScroll(draft, {
zoomOptions: options,
dimension: '2D',
Expand All @@ -438,24 +439,28 @@ function handleZoom(draft: Draft<State>, action: ZoomAction) {

case '1D': {
const activeSpectra = getActiveSpectra(draft);
const { shiftKey } = options;

// Horizontal zoom in/out 1d spectra by mouse wheel
if (selectedTool === 'zoom' && shiftKey) {
if (shiftKey) {
zoomWithScroll(draft, { zoomOptions: options, dimension: '1D' });
return;
}

if (!activeSpectra) {
// rescale the spectra vertically
if (!activeSpectra || activeSpectra.length > 1) {
const keys = !activeSpectra
? Object.keys(yDomains)
: activeSpectra.map(({ id }) => id);
// rescale the spectra
for (const key of Object.keys(yDomains)) {
for (const key of keys) {
const domain = yDomains[key];
yDomains[key] = wheelZoom(options, domain);
}
return;
}

if (activeSpectra.length === 1 && shiftKey) {
// rescale the integral in ranges and integrals
if (altKey) {
switch (selectedTool) {
case 'rangePicking': {
setRangesViewProperty(
Expand All @@ -476,13 +481,6 @@ function handleZoom(draft: Draft<State>, action: ZoomAction) {
default:
break;
}
} else {
for (const activeSpectrum of activeSpectra) {
const domain = yDomains?.[activeSpectrum?.id];
if (domain) {
yDomains[activeSpectrum?.id] = wheelZoom(options, domain);
}
}
}

break;
Expand Down

0 comments on commit b5d28f6

Please sign in to comment.