From fed250a758ae3000033ebb6001ffec427a4d4e1f Mon Sep 17 00:00:00 2001 From: Laszlo Korte Date: Thu, 4 Jul 2024 00:27:44 +0200 Subject: [PATCH] work around svelte bind:this state.frozen bug (sveltejs/svelte/issues/12287) --- src/svelte/Canvas/Root.svelte | 26 ++++---------------------- src/svelte/Canvas/tools/Spline.svelte | 1 - 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/svelte/Canvas/Root.svelte b/src/svelte/Canvas/Root.svelte index 8da0b04..c6775ce 100644 --- a/src/svelte/Canvas/Root.svelte +++ b/src/svelte/Canvas/Root.svelte @@ -65,21 +65,7 @@ import Zoom from "./tools/Zoom.svelte"; const svgElement = atom(null); - const currentToolElementRaw = atom(null); - - const currentToolElement = view( - L.lens(R.identity, (a, b) => { - // console.log(a); - // alert( - // "old:" + - // (b && Object.getOwnPropertyNames(b).join(",")) + - // ", new:" + - // (a && Object.getOwnPropertyNames(a).join(",")), - // ); - return a; - }), - currentToolElementRaw, - ); + let currentToolElement = $state(null); function clientToCanvas(x, y, screen = false) { const screenPoint = U.screenToElementViewbox( @@ -1549,11 +1535,8 @@ onclick={() => { currentDocumentContent.value = {}; - if ( - currentToolElement.value && - currentToolElement.value.cancel - ) { - currentToolElement.value.cancel(); + if (currentToolElement && currentToolElement.cancel) { + currentToolElement.cancel(); } update( @@ -1674,8 +1657,7 @@ diff --git a/src/svelte/Canvas/tools/Spline.svelte b/src/svelte/Canvas/tools/Spline.svelte index f68055f..ad263f9 100644 --- a/src/svelte/Canvas/tools/Spline.svelte +++ b/src/svelte/Canvas/tools/Spline.svelte @@ -149,7 +149,6 @@