mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
reset layout position on json edit
This commit is contained in:
parent
6a94a2c86c
commit
1aa5d8aecd
@ -25,6 +25,7 @@ const StyledEditorWrapper = styled.div`
|
||||
export const LiveEditor: React.FC = () => {
|
||||
const canvasRef = React.useRef<CanvasRef | null>(null);
|
||||
const wrapperRef = React.useRef<ReactZoomPanPinchRef | null>(null);
|
||||
|
||||
const [json] = useLocalStorage("json", JSON.stringify(defaultValue));
|
||||
const [config] = useLocalStorage<StorageConfig>("config", {
|
||||
layout: "LEFT",
|
||||
@ -34,6 +35,10 @@ export const LiveEditor: React.FC = () => {
|
||||
|
||||
const { nodes, edges } = getEdgeNodes(json);
|
||||
|
||||
const onLayoutChange = () => {
|
||||
wrapperRef.current?.resetTransform();
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledLiveEditor>
|
||||
<StyledEditorWrapper>
|
||||
@ -61,9 +66,7 @@ export const LiveEditor: React.FC = () => {
|
||||
center={false}
|
||||
readonly
|
||||
node={NodeWrapper}
|
||||
onLayoutChange={() => {
|
||||
canvasRef.current?.centerCanvas && canvasRef.current?.centerCanvas()
|
||||
}}
|
||||
onLayoutChange={onLayoutChange}
|
||||
/>
|
||||
</TransformComponent>
|
||||
</TransformWrapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user