fixed wrong initial set on store

This commit is contained in:
peterkogo
2024-04-10 12:02:16 +02:00
parent 91a642bb9c
commit 3a8b947260
4 changed files with 29 additions and 29 deletions
@@ -12,8 +12,8 @@
const { getIntersectingNodes } = useSvelteFlow();
function onNodeDrag({ detail: { node } }) {
const intersections = getIntersectingNodes(node).map((n) => n.id);
function onNodeDrag({ detail: { targetNode } }) {
const intersections = getIntersectingNodes(targetNode).map((n) => n.id);
$nodes.forEach((n) => {
n.class = intersections.includes(n.id) ? 'highlight' : '';
+4 -4
View File
@@ -75,7 +75,7 @@ export function createStore({
node.dragging = dragging;
}
store.nodes.set(get(store.nodes));
store.nodes.update((nds) => nds);
};
function updateNodeDimensions(updates: Map<string, NodeDimensionUpdate>) {
@@ -121,7 +121,7 @@ export function createStore({
}
}
store.nodes.set(get(store.nodes));
store.nodes.update((nds) => nds);
if (!get(store.nodesInitialized)) {
store.nodesInitialized.set(true);
@@ -205,10 +205,10 @@ export function createStore({
function unselectNodesAndEdges(params?: { nodes?: Node[]; edges?: Edge[] }) {
const resetNodes = resetSelectedElements(params?.nodes || get(store.nodes));
if (resetNodes) store.nodes.set(get(store.nodes));
if (resetNodes) store.nodes.update((nds) => nds);
const resetEdges = resetSelectedElements(params?.edges || get(store.edges));
if (resetEdges) store.edges.set(get(store.edges));
if (resetEdges) store.edges.update((nds) => nds);
}
store.deleteKeyPressed.subscribe(async (deleteKeyPressed) => {
+1 -1
View File
@@ -147,7 +147,7 @@ export const createNodesStore = (
checkEquality: false
});
value = nodes;
value = nds;
set(value);