Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable moveable programmatically #178

Open
chbert opened this issue Apr 2, 2023 · 3 comments
Open

Option to disable moveable programmatically #178

chbert opened this issue Apr 2, 2023 · 3 comments

Comments

@chbert
Copy link

chbert commented Apr 2, 2023

Hi @vnphanquang, great work on svelte-put!

I'm trying to find a way to disable "moveable" in certain instances programmatically.

I have a moveable canvas and moveable nodes on them. I tried to use the ignore parameter (as described here), but since I load the nodes within another component, it does not seem to work in this case. So, when I move a node, the underlying canvas also moves. So I'm listening to nodes moving and, during this time, would need to disable the grid moveable.

Maybe there is a workaround for this without a disable option?

Thanks!

This is the HTML of the canvas component (the nodes are inside the Graph component and have the class "node"):

<div
	class="canvas"
	class:disabled
	bind:this={canvasElement}
	use:movable={{
		limit: { delta: { x: `${$size.width * 2}px`, y: `${$size.height * 2}px` } },
		ignore: ".node"
	}}
	on:movablestart={onMoveableStart}
	on:movableend={onMoveableEnd}
>
	<Grid {gridElement} />
	<Graph bind:gridElement />
</div>
@vnphanquang vnphanquang added op:question scope:movable @svelte-put/movable labels Apr 2, 2023
@vnphanquang
Copy link
Owner

Hello there @chbert, glad this is being used.

I'm guessing the reason for this is because the .node elements are rendered after .canvas & the init phase of movable, in which the "ignored elements" are searched for.

This is on my part, i should have deferred ignore searching until in movablestart. Will release a patch for this tomorrow April 3rd. Hang tight.


FWIW, the workaround is to wait until the children have rendered and init / update movable but that's really bad for user ergonomics and does not completely resolve runtime dynamic DOM update.

@vnphanquang
Copy link
Owner

@chbert @svelte-put/[email protected] should resolve the issue you've described. Please give it a try at your convenience and let me know. Thanks

@chbert
Copy link
Author

chbert commented Apr 3, 2023

@vnphanquang thanks for the prompt reply! I tested it, but still have the same result. I will try to put together a REPL to reproduce it more easily. Make take a moment :-D

@vnphanquang vnphanquang removed their assignment Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Blocked
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants