Skip to content

Commit

Permalink
fix: spectra stack alignment does not work when load .nmrium
Browse files Browse the repository at this point in the history
close #1495
  • Loading branch information
hamed-musallam committed Apr 22, 2022
1 parent dd470ce commit 33ce29b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/component/reducer/actions/LoadActions.ts
Expand Up @@ -100,9 +100,9 @@ function initiate(draft: Draft<State>, action) {
setData(state, action.payload);
const preferences = action.payload?.preferences || {};
setActiveTab(state, { tab: preferences?.activeTab || '' });
setPreferences(state, action.payload);
state.width = draft.width;
state.height = draft.height;
setPreferences(state, action.payload);
state.isLoading = false;
state.actionType = INITIATE;
return state;
Expand Down Expand Up @@ -138,10 +138,9 @@ function handleLoadJsonFile(draft: Draft<State>, action) {
setData(state, action.payload);
const preferences = action.payload?.preferences || {};
setActiveTab(state, { tab: preferences?.activeTab || '' });
setPreferences(state, preferences);

state.width = draft.width;
state.height = draft.height;
setPreferences(state, preferences);
state.isLoading = false;
state.actionType = LOAD_JSON_FILE;
return state;
Expand Down
6 changes: 4 additions & 2 deletions src/component/reducer/actions/PreferencesActions.ts
Expand Up @@ -55,8 +55,10 @@ function changeSpectrumVerticalAlignment(
const visibleSpectra = dataPerNucleus.filter(
(datum) => datum.display.isVisible === true,
);
draft.verticalAlign.verticalShift = Math.floor(
(draft.height - draft.margin.bottom) / (visibleSpectra.length + 2),
draft.verticalAlign.verticalShift = Math.abs(
Math.floor(
(draft.height - draft.margin.bottom) / (visibleSpectra.length + 2),
),
);
break;
}
Expand Down

0 comments on commit 33ce29b

Please sign in to comment.