refactor(updates): only trigger dim updates when dim changed
This commit is contained in:
@@ -5,10 +5,10 @@ import {
|
||||
fitView as fitViewUtil,
|
||||
getElementsToRemove,
|
||||
panBy as panBySystem,
|
||||
updateNodeDimensions as updateNodeDimensionsSystem,
|
||||
updateNodeInternals as updateNodeInternalsSystem,
|
||||
addEdge as addEdgeUtil,
|
||||
type UpdateNodePositions,
|
||||
type NodeDimensionUpdate,
|
||||
type InternalNodeUpdate,
|
||||
type ViewportHelperFunctionOptions,
|
||||
type Connection,
|
||||
type XYPosition,
|
||||
@@ -78,16 +78,16 @@ export function createStore({
|
||||
store.nodes.update((nds) => nds);
|
||||
};
|
||||
|
||||
function updateNodeDimensions(updates: Map<string, NodeDimensionUpdate>) {
|
||||
function updateNodeInternals(updates: Map<string, InternalNodeUpdate>) {
|
||||
const nodeLookup = get(store.nodeLookup);
|
||||
const changes = updateNodeDimensionsSystem(
|
||||
const { changes, updatedInternals } = updateNodeInternalsSystem(
|
||||
updates,
|
||||
nodeLookup,
|
||||
get(store.domNode),
|
||||
get(store.nodeOrigin)
|
||||
);
|
||||
|
||||
if (!changes) {
|
||||
if (!updatedInternals) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ export function createStore({
|
||||
setEdgeTypes,
|
||||
addEdge,
|
||||
updateNodePositions,
|
||||
updateNodeDimensions,
|
||||
updateNodeInternals,
|
||||
zoomIn,
|
||||
zoomOut,
|
||||
fitView: (options?: FitViewOptions) => fitView(options),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Writable } from 'svelte/store';
|
||||
import type {
|
||||
NodeDimensionUpdate,
|
||||
InternalNodeUpdate,
|
||||
XYPosition,
|
||||
ViewportHelperFunctionOptions,
|
||||
Connection,
|
||||
@@ -27,7 +27,7 @@ export type SvelteFlowStoreActions = {
|
||||
setTranslateExtent: (extent: CoordinateExtent) => void;
|
||||
fitView: (options?: FitViewOptions) => boolean;
|
||||
updateNodePositions: UpdateNodePositions;
|
||||
updateNodeDimensions: (updates: Map<string, NodeDimensionUpdate>) => void;
|
||||
updateNodeInternals: (updates: Map<string, InternalNodeUpdate>) => void;
|
||||
unselectNodesAndEdges: (params?: { nodes?: Node[]; edges?: Edge[] }) => void;
|
||||
addSelectedNodes: (ids: string[]) => void;
|
||||
addSelectedEdges: (ids: string[]) => void;
|
||||
|
||||
Reference in New Issue
Block a user