Skip to content

Commit

Permalink
work around svelte bind:this state.frozen bug (sveltejs/svelte/issues…
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlokorte committed Jul 3, 2024
1 parent 5534532 commit fed250a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
26 changes: 4 additions & 22 deletions src/svelte/Canvas/Root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -1549,11 +1535,8 @@
onclick={() => {
currentDocumentContent.value = {};

if (
currentToolElement.value &&
currentToolElement.value.cancel
) {
currentToolElement.value.cancel();
if (currentToolElement && currentToolElement.cancel) {
currentToolElement.cancel();
}

update(
Expand Down Expand Up @@ -1674,8 +1657,7 @@

<svelte:component
this={tools[tool.value].component}
key={tool.value}
bind:this={currentToolElement.value}
bind:this={currentToolElement}
{...tools[tool.value].parameters}
></svelte:component>
</svg>
Expand Down
1 change: 0 additions & 1 deletion src/svelte/Canvas/tools/Spline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
</script>

<path
use:disableTouchEventsIf={startPath}
class="polygon-surface"
d={frameBoxPath.value}
pointer-events="all"
Expand Down

0 comments on commit fed250a

Please sign in to comment.