feat(network): preserve pan and scale on data reload

This commit is contained in:
Sergey Krashevich
2024-06-16 15:01:40 +03:00
parent a69eb8a66e
commit cb44d5431a

View File

@@ -68,6 +68,8 @@
network.storePositions(); network.storePositions();
} else { } else {
const positions = network.getPositions(); const positions = network.getPositions();
const viewState = network.getViewPosition();
const scale = network.getScale();
network.setData(data); network.setData(data);
@@ -76,6 +78,8 @@
network.moveNode(nodeId, positions[nodeId].x, positions[nodeId].y); network.moveNode(nodeId, positions[nodeId].x, positions[nodeId].y);
} }
} }
network.moveTo({ position: viewState, scale: scale });
} }
} catch (error) { } catch (error) {