Fix/draggable offset position
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
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?
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 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?
@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. 👍🏼
I like it a lot! Thanks for your work and your patience with me.
Hey @maccesch thanks for the reviews and your feedback!