leptos-use icon indicating copy to clipboard operation
leptos-use copied to clipboard

Fix/draggable offset position

Open theredfish opened this issue 8 months ago • 1 comments

The current implementation of use_draggable only works for elements with a fixed position where the boundaries are relative to the window.

In order to support other positions, we need to generalize the offset calculation so a user can provide its own function.

Fix https://github.com/Synphonyte/leptos-use/issues/107

theredfish avatar Apr 28 '25 20:04 theredfish

Hi @maccesch

Can I get a pre-review of this work? I didn't try the example in the book yet, I just run it locally. It gives a use case for both fixed and absolute positions.

I tried to follow your recommendation for generalizing the offset function. So far seems to work. I pushed the example a little bit further with clamped values so we can't go outside the parent container. I think it's the main use case of an absolute draggable element.

What do you think?

theredfish avatar Apr 28 '25 22:04 theredfish

Thanks for your work!

I'm not sure what you me an with a "preview". You're already running the example locally. Isn't that a preview?

Actually I don't think that moving the element inside the bounds of another is the main use case. I like the extension to the function but I'd like to keep the example simple.

maccesch avatar Apr 29 '25 15:04 maccesch

@maccesch thanks! I was asking for a quick review before the final one (pre-review). Sorry for the confusion. Just to be sure I'm in the right direction.

ok I will keep the example straightforward then. Should I keep the example with both fixed/absolute positions (no boundaries check) or just revert to the original example?

theredfish avatar Apr 29 '25 16:04 theredfish

@maccesch thanks! I was asking for a quick review before the final one (pre-review). Sorry for the confusion. Just to be sure I'm in the right direction.

ok I will keep the example straightforward then. Should I keep the example with both fixed/absolute positions (no boundaries check) or just revert to the original example?

No I think to showcase the different positions is a good idea. 👍🏼

maccesch avatar May 01 '25 02:05 maccesch

I like it a lot! Thanks for your work and your patience with me.

maccesch avatar May 08 '25 01:05 maccesch

Hey @maccesch thanks for the reviews and your feedback!

theredfish avatar May 09 '25 07:05 theredfish