Browse Source

center canvas on init

AykutSarac 3 years ago
parent
commit
8eb7cbd020
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/containers/LiveEditor/index.tsx

+ 4 - 2
src/containers/LiveEditor/index.tsx

@@ -36,11 +36,12 @@ const wheelOptions = {
 export const LiveEditor: React.FC = React.memo(function LiveEditor() {
   const { dispatch } = useConfig();
 
-  const onInit = (ref: ReactZoomPanPinchRef) =>
+  const onInit = (ref: ReactZoomPanPinchRef) => {
     dispatch({
       type: ConfigActionType.SET_ZOOM_PAN_PICNH_REF,
       payload: ref,
     });
+  };
 
   return (
     <StyledLiveEditor>
@@ -49,9 +50,10 @@ export const LiveEditor: React.FC = React.memo(function LiveEditor() {
         <TransformWrapper
           maxScale={1.8}
           minScale={0.4}
-          initialScale={0.8}
+          initialScale={0.9}
           wheel={wheelOptions}
           onInit={onInit}
+          centerOnInit
         >
           <TransformComponent
             wrapperStyle={{