From 5f015c45399a3e771ad9632464e2aac5102b61a1 Mon Sep 17 00:00:00 2001 From: Mark Mankarious Date: Wed, 11 Oct 2023 10:47:57 +0100 Subject: [PATCH] feat: changes starting mode to PAN --- src/config.ts | 6 +++++- src/stores/uiStateStore.tsx | 15 ++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/config.ts b/src/config.ts index 43765aa..35dd40e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,4 @@ -import { Size, Coords, SceneInput, Connector } from 'src/types'; +import { Size, Coords, SceneInput, Connector, Mode } from 'src/types'; import { customVars } from './styles/theme'; // TODO: This file could do with better organisation and convention for easier reading. @@ -49,3 +49,7 @@ export const INITIAL_SCENE: SceneInput = { textBoxes: [], rectangles: [] }; +export const STARTING_MODE: Mode = { + type: 'PAN', + showCursor: false +}; diff --git a/src/stores/uiStateStore.tsx b/src/stores/uiStateStore.tsx index 0b03f97..877d676 100644 --- a/src/stores/uiStateStore.tsx +++ b/src/stores/uiStateStore.tsx @@ -2,6 +2,7 @@ import React, { createContext, useContext, useRef } from 'react'; import { createStore, useStore } from 'zustand'; import { CoordsUtils, incrementZoom, decrementZoom } from 'src/utils'; import { UiStateStore } from 'src/types'; +import { STARTING_MODE } from 'src/config'; const initialState = () => { return createStore((set, get) => { @@ -9,11 +10,7 @@ const initialState = () => { iconCategoriesState: [], disableInteractions: false, hideMainMenu: false, - mode: { - type: 'CURSOR', - showCursor: true, - mousedownItem: null - }, + mode: STARTING_MODE, isMainMenuOpen: false, mouse: { position: { screen: CoordsUtils.zero(), tile: CoordsUtils.zero() }, @@ -35,11 +32,7 @@ const initialState = () => { }, resetUiState: () => { set({ - mode: { - type: 'CURSOR', - showCursor: true, - mousedownItem: null - }, + mode: STARTING_MODE, scroll: { position: CoordsUtils.zero(), offset: CoordsUtils.zero() @@ -91,7 +84,7 @@ const initialState = () => { set({ mode: { type: 'INTERACTIONS_DISABLED', showCursor: false } }); } else { set({ - mode: { type: 'CURSOR', showCursor: true, mousedownItem: null } + mode: STARTING_MODE }); } },