From 7668b12abb5d0370892c629ed43255e798b38a92 Mon Sep 17 00:00:00 2001 From: exyi Date: Mon, 28 Sep 2020 17:10:01 +0000 Subject: [PATCH] Remove weird hack - we can just call functions on components fix #4 --- frontend/src/Editor.svelte | 9 +++------ frontend/src/Graph.svelte | 10 +--------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/frontend/src/Editor.svelte b/frontend/src/Editor.svelte index ad48a12..a4f1673 100644 --- a/frontend/src/Editor.svelte +++ b/frontend/src/Editor.svelte @@ -51,16 +51,13 @@ tasks = tasks; // run simulation - toggleDivnaPromena(); + graph.runSimulation() } else { alert("Nope, prvni musis nekam klikat..."); } } - let hovnoDivnaPromenaKteraJeFaktFuj = true; - function toggleDivnaPromena() { - hovnoDivnaPromenaKteraJeFaktFuj = !hovnoDivnaPromenaKteraJeFaktFuj; - } + let graph: Graph async function saveCurrentState() { await saveTasks(tasks); @@ -127,7 +124,7 @@ {repulsionForce} bind:selectedTask on:selectTask={clickTask} - runSimulationWeirdHack={hovnoDivnaPromenaKteraJeFaktFuj} /> + bind:this={graph} />
diff --git a/frontend/src/Graph.svelte b/frontend/src/Graph.svelte index 60095de..4f6a112 100644 --- a/frontend/src/Graph.svelte +++ b/frontend/src/Graph.svelte @@ -38,7 +38,7 @@ } }; - function runSimulation() { + export function runSimulation() { // Let's list the force we wanna apply on the network let simulation = d3 .forceSimulation(nodes) // Force algorithm is applied to data.nodes @@ -84,14 +84,6 @@ let zoomer = d3.zoom().scaleExtent([0.1, 2]).on("zoom", zoomed); d3.select(container).call(zoomer); }); - - // don't forget to vomit 🤮🤢 - export let runSimulationWeirdHack: boolean = false; - $: { - runSimulationWeirdHack; - runSimulation(); - } - // now it's safe to stop vomitting 🤮