refactor(noderenderer): add viewportBox to store

This commit is contained in:
moklick
2020-07-29 10:48:16 +02:00
parent 16707eaa99
commit f4d1af6589
2 changed files with 6 additions and 7 deletions
+4 -2
View File
@@ -54,6 +54,7 @@ type SetSnapGrid = {
export interface StoreModel {
width: number;
height: number;
viewportBox: Computed<StoreModel, Rect>;
transform: Transform;
elements: Elements;
nodes: Computed<StoreModel, Node[]>;
@@ -136,10 +137,11 @@ export interface StoreModel {
export const storeModel: StoreModel = {
width: 0,
height: 0,
viewportBox: computed((state) => ({ x: 0, y: 0, width: state.width, height: state.height })),
transform: [0, 0, 1],
elements: [],
nodes: computed([(state) => state.elements], (elements) => elements.filter((el) => isNode(el)) as Node[]),
edges: computed([(state) => state.elements], (elements) => elements.filter((el) => isEdge(el)) as Edge[]),
nodes: computed((state) => state.elements.filter((el) => isNode(el)) as Node[]),
edges: computed((state) => state.elements.filter((el) => isEdge(el)) as Edge[]),
selectedElements: null,
selectedNodesBbox: { x: 0, y: 0, width: 0, height: 0 },