Fix some bugs
This commit is contained in:
@ -13,10 +13,7 @@ export const ExcalidrawMain = () => {
|
|||||||
|
|
||||||
const [toggleState, setToggleState] = useState<boolean>(false);
|
const [toggleState, setToggleState] = useState<boolean>(false);
|
||||||
|
|
||||||
const onClose = useCallback(
|
const onClose = useCallback(() => setToggleState(false), []);
|
||||||
() => setToggleState(!toggleState),
|
|
||||||
[toggleState]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExcalidrawContainer
|
<ExcalidrawContainer
|
||||||
|
@ -3,7 +3,7 @@ import type {
|
|||||||
ExcalidrawProps,
|
ExcalidrawProps,
|
||||||
ExcalidrawImperativeAPI,
|
ExcalidrawImperativeAPI,
|
||||||
} from '@excalidraw/excalidraw/types/types';
|
} from '@excalidraw/excalidraw/types/types';
|
||||||
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
import { FC, useEffect, useMemo, useState } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
export type WindowRect = {
|
export type WindowRect = {
|
||||||
@ -46,17 +46,17 @@ export const ExcalidrawContainer: FC<ExcalidrawContainerProps> = (props) => {
|
|||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
const onResize = useCallback(() => {
|
const onResize = () => {
|
||||||
setWindowRect({
|
setWindowRect({
|
||||||
width: window.innerWidth,
|
width: window.innerWidth,
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
});
|
});
|
||||||
}, []);
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('resize', onResize);
|
window.addEventListener('resize', onResize);
|
||||||
return () => window.removeEventListener('resize', onResize);
|
return () => window.removeEventListener('resize', onResize);
|
||||||
}, [onResize]);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExcalidrawBox $scale={scale} $windowRect={windowRect}>
|
<ExcalidrawBox $scale={scale} $windowRect={windowRect}>
|
||||||
|
@ -21,7 +21,7 @@ const RightTopUI: FC<RightTopUIProps> = (props) => {
|
|||||||
const sidebarToggle = useCallback(
|
const sidebarToggle = useCallback(
|
||||||
(variant: SidebarVariant) => {
|
(variant: SidebarVariant) => {
|
||||||
if (excalidrawAPI && !props.toggleState) {
|
if (excalidrawAPI && !props.toggleState) {
|
||||||
props.setToggleState(props.toggleState);
|
props.setToggleState(true);
|
||||||
props.setSidebarVariant(variant);
|
props.setSidebarVariant(variant);
|
||||||
excalidrawAPI.toggleMenu('customSidebar');
|
excalidrawAPI.toggleMenu('customSidebar');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user