-
Notifications
You must be signed in to change notification settings - Fork 105
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
223 - added a cancelable USER_DROPPED consider event on the origin zone #232
base: master
Are you sure you want to change the base?
Conversation
…ne if the dragged element was dropped outside of any. cancelling skips the final animation to place and dispatches the finalize events right away
This looks good. I will try to use in my dnd implementation in Relm and see if anything comes up. |
let me know if you have any feedback. I am hoping to spend more time on this over the weekend |
I will have time tomorrow (Friday) to visit this. Apologies for the delay.
…On Thu, Jan 21, 2021 at 3:21 AM Isaac Hagoel ***@***.***> wrote:
let me know if you have any feedback. I am hoping to spend more time on
this over the weekend
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAABAI4YY6V4W5OYBPHRWDS275Z5ANCNFSM4WIT65SA>
.
|
All my tests check out! This accomplishes what my 'customDrop' PR does and without introducing a new config option. |
mmm... i've been playing with it but on my new example (with files and folders) it looks like for some reason the event is always cancelled (without me calling prevent default). I am not sure why. still investigating. |
alright. i fixed it. now it behaves correctly in both cases. will proceed testing it in context later. |
Sorry, I was blocked this week, can take a look later. If this helps his usecase, you can merge this at any time. |
Is this ready to be merged in? |
sorry. I found some issues while testing it.
also, I started to doubt this approach in general, doubting it can go the
whole way.
does it work perfectly for you?
…On Tue, Feb 9, 2021 at 4:42 PM Duane Johnson ***@***.***> wrote:
Is this ready to be merged in?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC5IW5CHGQNZ66NDVF3S6DDK3ANCNFSM4WIT65SA>
.
|
Yes, it seems to work well. It was a near drop-in replacement for the customDrop approach I'd tried earlier (no pun intended!) |
Alright. I will resume looking into it
…On Wed, Feb 10, 2021, 01:18 Duane Johnson ***@***.***> wrote:
Yes, it seems to work well. It was a near drop-in replacement for the
customDrop approach I'd tried earlier (no pun intended!)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC6NV5ULOXDTBMWJZQTS6E7ZZANCNFSM4WIT65SA>
.
|
Thank you! |
@canadaduane can you remind me pls... is there a reason i decided to dispatch the new "USER_DROPPED" event only when the dragged element is outside of any zone? why didn't i make the library dispatch it and allow cancelling the final animation regardless of where it was dropped (which makes more sense to me when i think about it now)? also, note to self - instead of conditional logic around whether or not to play the animation we can set the duration of the animation to zero if the event was cancelled |
… triggers on any pointer drop and change the duration of the animation to zero if cancelled instead of branching the code. added isDroppedOutsideOfAnyDzOfType as a property of the event.
reply to self: I did it this way because otherwise the user code doesn't have enough information to decide whether to cancel the drop or not (dropped where). const {items: newItems, info: {trigger, pointerClientXY, isDroppedOutsideOfAnyDzOfType}} = e.detail;
if (trigger === TRIGGERS.USER_DROPPED && isDroppedOutsideOfAnyDzOfType) {
e.preventDefault();
} Now I wonder whether this is the time and place to introduce a new event type in addition to Also, @Florian-Schoenherr did u get to try it with the whiteboard example? |
I'm gonna try it now. |
@Florian-Schoenherr sorry, i only saw your edit now. you use 'npm link' in order to make your repo use the local version of the library. |
not sure i follow. it might be an issue that was recently fixed on the master branch. can u pls provide some files with code that i can used in order to reproduce this error? |
But I found out what the bug was: Now after that change, I can do: const considerGroup = (e) => {
if (e.detail.info.trigger === TRIGGERS.USER_DROPPED) {
const group = itemGroups.find(g => g.id === "id:dnd-shadow-placeholder-0000");
group.x = e.detail.info.draggedElement.getBoundingClientRect().x;
group.y = e.detail.info.draggedElement.getBoundingClientRect().y;
e.preventDefault();
}
itemGroups = e.detail.items;
} but finalize still runs, so uhh, would I then replace the shadow item myself? group.x = e.detail.info.draggedElement.getBoundingClientRect().x;
group.y = e.detail.info.draggedElement.getBoundingClientRect().y;
group.id = e.detail.info.id;
delete group["isDndShadowItem"];
e.preventDefault(); it works.
Code (just focused on the group here) |
it is an older branch that's why some newer features might not be available.
do i need to check/debug something or does it meet your requirements (this
branch)?
…On Sat, Apr 17, 2021 at 3:25 PM Florian-Schoenherr ***@***.***> wrote:
getBoundingRectNoTransforms(shadowElDropZone.children[shadowElIdx]);
in this case will do
getBoundingRectNoTransforms(shadowElDropZone.children[2]);
but
shadowElDropZone.children is [0: div, 1: div], so does not have an
element at index 2.
But I found out what the bug was:
In one of the consider functions I did itemGroups = itemGroups instead of itemGroups
= e.detail.items; 😅
Now after that change, I can do:
const considerGroup = (e) => {
if (e.detail.info.trigger === TRIGGERS.USER_DROPPED) {
const { x, y } = e.detail.info.pointerClientXY;
const group = itemGroups.find(g => g.id === "id:dnd-shadow-placeholder-0000");
group.x = x;
group.y = y;
e.preventDefault();
}
itemGroups = e.detail.items;
}
but finalize still runs, so uhh, would I then replace the shadow item
myself?
If I leave away finalize completely and instead of the above, change it to:
group.x = x;
group.y = y;
group.id = e.detail.info.id;
delete group["isDndShadowItem"];
e.preventDefault();
it works.
SHADOW_PLACEHOLDER_ITEM_ID doesn't seem to be exported any longer
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC4AIUFT76T5LRZ7FO3TJELS5ANCNFSM4WIT65SA>
.
|
@isaacHagoel do you think the code in the REPL makes sense? I just hacked that together somehow, seemed a little like I was fighting the intended way, otherwise yeah, it works. |
I haven't really looked (i am on vacation this weekend). Will let you know
…On Sat, Apr 17, 2021, 21:06 Florian-Schoenherr ***@***.***> wrote:
@isaacHagoel <https://github.com/isaacHagoel> do you think the code in
the REPL makes sense? I just hacked that together somehow, seemed a little
like I was fighting the intended way, otherwise yeah, it works.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZC2C6E5O2WAVMU75Y7TTJFTTHANCNFSM4WIT65SA>
.
|
@isaacHagoel have a nice weekend :) |
what is the desired behaviour in that REPL? freely dragging the groups around and be able to move items between groups? |
Yeah, dragging the groups around, moving between groups and when dragging one item outside a group, adding it to it's own, new group. It works but seems hacky. |
It does seem hacky. Will try to find time to improve it tomorrow
…On Mon, Apr 19, 2021, 21:14 Florian-Schoenherr ***@***.***> wrote:
Yeah, dragging the groups around, moving between groups and when dragging
one item outside a group, adding it to it's own, new group. It works but
seems hacky.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE4OZCYC7XXSBUIOKZDR24TTJQF7VANCNFSM4WIT65SA>
.
|
I played with it a bit and indeed this usecase (especially the need to create a new group when the item is dropped outside of any, remove the item manually from the original group and so on) doesn't feel nice to implement.
|
@isaacHagoel will take a look soon. |
Yes, composability & ability to think about these actions / outcomes
separately is a very nice-to-have. I found it slightly difficult to think
about internal state of svelte-dnd-action while also crafting the UI
concepts I needed for my app. I'm grateful for your work here, though, as I
tried several other libraries and it wasn't "easy" in those cases either.
…On Tue, Apr 20, 2021 at 8:25 AM Florian-Schoenherr ***@***.***> wrote:
@isaacHagoel <https://github.com/isaacHagoel> will take a look soon.
I wonder if there's a way to keep all this
dnd/whiteboard/Shopify-draggable usecase stuff idiomatic, easy to compose
etc.
Of course you can't expand scope endlessly (although I think you've done a
great job with the current functionality and would probably be able to do
more of this kind of thing).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#232 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAABALYTJE5FXWNJC6TJ33TJWFGTANCNFSM4WIT65SA>
.
|
added a cancelable USER_DROPPED consider event on the origin zone if the dragged element was dropped outside of any. cancelling skips the final animation to place and dispatches the finalize events right away.
the info provided in the event:
example usage within the consider handler:
missing updates to README and types
resolves #223