feat: changes starting mode to PAN

This commit is contained in:
Mark Mankarious 2023-10-11 10:47:57 +01:00
parent 4de4882b03
commit 5f015c4539
2 changed files with 9 additions and 12 deletions

View file

@ -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'; import { customVars } from './styles/theme';
// TODO: This file could do with better organisation and convention for easier reading. // TODO: This file could do with better organisation and convention for easier reading.
@ -49,3 +49,7 @@ export const INITIAL_SCENE: SceneInput = {
textBoxes: [], textBoxes: [],
rectangles: [] rectangles: []
}; };
export const STARTING_MODE: Mode = {
type: 'PAN',
showCursor: false
};

View file

@ -2,6 +2,7 @@ import React, { createContext, useContext, useRef } from 'react';
import { createStore, useStore } from 'zustand'; import { createStore, useStore } from 'zustand';
import { CoordsUtils, incrementZoom, decrementZoom } from 'src/utils'; import { CoordsUtils, incrementZoom, decrementZoom } from 'src/utils';
import { UiStateStore } from 'src/types'; import { UiStateStore } from 'src/types';
import { STARTING_MODE } from 'src/config';
const initialState = () => { const initialState = () => {
return createStore<UiStateStore>((set, get) => { return createStore<UiStateStore>((set, get) => {
@ -9,11 +10,7 @@ const initialState = () => {
iconCategoriesState: [], iconCategoriesState: [],
disableInteractions: false, disableInteractions: false,
hideMainMenu: false, hideMainMenu: false,
mode: { mode: STARTING_MODE,
type: 'CURSOR',
showCursor: true,
mousedownItem: null
},
isMainMenuOpen: false, isMainMenuOpen: false,
mouse: { mouse: {
position: { screen: CoordsUtils.zero(), tile: CoordsUtils.zero() }, position: { screen: CoordsUtils.zero(), tile: CoordsUtils.zero() },
@ -35,11 +32,7 @@ const initialState = () => {
}, },
resetUiState: () => { resetUiState: () => {
set({ set({
mode: { mode: STARTING_MODE,
type: 'CURSOR',
showCursor: true,
mousedownItem: null
},
scroll: { scroll: {
position: CoordsUtils.zero(), position: CoordsUtils.zero(),
offset: CoordsUtils.zero() offset: CoordsUtils.zero()
@ -91,7 +84,7 @@ const initialState = () => {
set({ mode: { type: 'INTERACTIONS_DISABLED', showCursor: false } }); set({ mode: { type: 'INTERACTIONS_DISABLED', showCursor: false } });
} else { } else {
set({ set({
mode: { type: 'CURSOR', showCursor: true, mousedownItem: null } mode: STARTING_MODE
}); });
} }
}, },