feat: store camera position in localStorage

This commit is contained in:
max_richter 2024-03-19 16:47:43 +01:00
parent d1d9d7ecae
commit 3811a6bdb4
3 changed files with 11 additions and 7 deletions

View File

@ -4,7 +4,6 @@
import NodeHeader from "./NodeHeader.svelte";
import NodeParameter from "./NodeParameter.svelte";
import { activeNodeId, selectedNodes } from "./graph/stores";
import { getGraphManager } from "./graph/context";
export let node: Node;
export let inView = true;
@ -18,7 +17,10 @@
let ref: HTMLDivElement;
$: if (node) {
$: if (node && ref) {
node.tmp = node.tmp || {};
node.tmp.ref = ref;
updateNodePosition(node);
}
onMount(() => {

View File

@ -103,7 +103,7 @@ export class GraphManager {
setTimeout(() => {
this.status.set("idle");
this.history.save();
this.save();
}, 100)
}
@ -155,7 +155,7 @@ export class GraphManager {
nodes.delete(node.id);
return nodes;
});
this.history.save();
this.save();
}
createEdge(from: Node, fromSocket: number, to: Node, toSocket: string) {
@ -183,6 +183,10 @@ export class GraphManager {
return [...edges.filter(e => e[2].id !== to.id || e[3] !== toSocket), [from, fromSocket, to, toSocket]];
});
this.save();
}
save() {
this.history.save();
}
@ -260,7 +264,7 @@ export class GraphManager {
this.edges.update((edges) => {
return edges.filter((e) => e[0].id !== id0 || e[1] !== sid0 || e[2].id !== id2 || e[3] !== sid2);
});
this.history.save();
this.save();
}
getEdgesToNode(node: Node) {

View File

@ -2,8 +2,6 @@
import { Canvas } from "@threlte/core";
import { GraphManager } from "$lib/graph-manager";
import Graph from "$lib/components/graph/Graph.svelte";
import Details from "$lib/elements/Details.svelte";
import { JsonView } from "@zerodevx/svelte-json-view";
import { MemoryRuntimeExecutor } from "$lib/runtime-executor";
import { MemoryNodeRegistry } from "$lib/node-registry";