mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix reducer ref not working
This commit is contained in:
parent
a3f0833be5
commit
20fe0bd6d0
@ -25,8 +25,6 @@ export const useConfigReducer: React.Reducer<AppConfig, ReducerAction> = (
|
||||
state = initialStates,
|
||||
action
|
||||
) => {
|
||||
if (!state.settings.zoomPanPinch) return state;
|
||||
|
||||
switch (action.type) {
|
||||
case ConfigActionType.SET_CONFIG:
|
||||
return { ...state, settings: action.payload };
|
||||
@ -50,22 +48,22 @@ export const useConfigReducer: React.Reducer<AppConfig, ReducerAction> = (
|
||||
};
|
||||
|
||||
case ConfigActionType.CENTER_VIEW:
|
||||
state.settings.zoomPanPinch.resetTransform();
|
||||
state.settings.zoomPanPinch?.resetTransform();
|
||||
return state;
|
||||
|
||||
case ConfigActionType.ZOOM_IN:
|
||||
state.settings.zoomPanPinch.setTransform(
|
||||
state.settings.zoomPanPinch.state.positionX,
|
||||
state.settings.zoomPanPinch.state.positionY,
|
||||
state.settings.zoomPanPinch.state.scale + 0.2
|
||||
state.settings.zoomPanPinch?.setTransform(
|
||||
state.settings.zoomPanPinch?.state.positionX,
|
||||
state.settings.zoomPanPinch?.state.positionY,
|
||||
state.settings.zoomPanPinch?.state.scale + 0.2
|
||||
);
|
||||
return state;
|
||||
|
||||
case ConfigActionType.ZOOM_OUT:
|
||||
state.settings.zoomPanPinch.setTransform(
|
||||
state.settings.zoomPanPinch.state.positionX,
|
||||
state.settings.zoomPanPinch.state.positionY,
|
||||
state.settings.zoomPanPinch.state.scale - 0.2
|
||||
state.settings.zoomPanPinch?.setTransform(
|
||||
state.settings.zoomPanPinch?.state.positionX,
|
||||
state.settings.zoomPanPinch?.state.positionY,
|
||||
state.settings.zoomPanPinch?.state.scale - 0.2
|
||||
);
|
||||
return state;
|
||||
|
||||
|
@ -7,5 +7,5 @@ export interface StorageConfig {
|
||||
autoformat: boolean;
|
||||
hideEditor: boolean;
|
||||
searchNode: string;
|
||||
zoomPanPinch?: ReactZoomPanPinchRef;
|
||||
zoomPanPinch: ReactZoomPanPinchRef | null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user