resolved some requested changes

This commit is contained in:
peterkogo
2024-04-10 14:47:49 +02:00
parent db05c3f3f4
commit 835dec25ba
13 changed files with 39 additions and 43 deletions
+9 -9
View File
@@ -80,14 +80,14 @@ export function createStore({
function updateNodeDimensions(updates: Map<string, NodeDimensionUpdate>) {
const nodeLookup = get(store.nodeLookup);
const nodeUpdates = updateNodeDimensionsSystem(
const changes = updateNodeDimensionsSystem(
updates,
nodeLookup,
get(store.domNode),
get(store.nodeOrigin)
);
if (!nodeUpdates) {
if (!changes) {
return;
}
@@ -100,23 +100,23 @@ export function createStore({
store.fitViewOnInitDone.set(fitViewOnInitDone);
}
for (const nodeUpdate of nodeUpdates) {
const node = nodeLookup.get(nodeUpdate.id)?.internals.userNode;
for (const change of changes) {
const node = nodeLookup.get(change.id)?.internals.userNode;
if (!node) {
continue;
}
switch (nodeUpdate.type) {
switch (change.type) {
case 'dimensions': {
const measured = { ...node.measured, ...nodeUpdate.dimensions };
node.width = nodeUpdate.dimensions?.width ?? node.width;
node.height = nodeUpdate.dimensions?.height ?? node.height;
const measured = { ...node.measured, ...change.dimensions };
node.width = change.dimensions?.width ?? node.width;
node.height = change.dimensions?.height ?? node.height;
node.measured = measured;
break;
}
case 'position':
node.position = nodeUpdate.position ?? node.position;
node.position = change.position ?? node.position;
break;
}
}
@@ -93,7 +93,7 @@ export const getInitialStore = ({
let viewport: Viewport = { x: 0, y: 0, zoom: 1 };
if (fitView && width && height) {
const nodesWithDimensions = Array.from(nodeLookup.values()).filter(
const nodesWithDimensions = nodes.filter(
(node) => (node.width && node.height) || (node.initialWidth && node.initialHeight)
);