Typescript

This commit is contained in:
Mitchell McCaffrey
2021-07-16 16:58:14 +10:00
parent d80bfa2f1e
commit c7b8990a7b
19 changed files with 97 additions and 74 deletions

View File

@@ -23,6 +23,8 @@ import MapGrid from "./MapGrid";
import MapGridEditor from "./MapGridEditor";
import { Map } from "../../types/Map";
import { GridInset } from "../../types/Grid";
import { Stage as StageType } from "konva/types/Stage";
import { Layer as LayerType } from "konva/types/Layer";
type MapSettingsChangeEventHandler = (change: Partial<Map>) => void;
@@ -41,8 +43,8 @@ function MapEditor({ map, onSettingsChange }: MapEditorProps) {
const defaultInset = getGridDefaultInset(map.grid, map.width, map.height);
const stageTranslateRef = useRef({ x: 0, y: 0 });
const mapStageRef = useRef();
const mapLayerRef = useRef();
const mapStageRef = useRef<StageType>(null);
const mapLayerRef = useRef<LayerType>(null);
const [preventMapInteraction, setPreventMapInteraction] = useState(false);
function handleResize(width?: number, height?: number): void {
@@ -55,7 +57,7 @@ function MapEditor({ map, onSettingsChange }: MapEditorProps) {
}
}
const containerRef = useRef(null);
const containerRef = useRef<HTMLDivElement>(null);
usePreventOverscroll(containerRef);
const [mapWidth, mapHeight] = useImageCenter(