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

Items' UI change during dragged #601

Open
gosongying opened this issue Sep 15, 2024 · 23 comments
Open

Items' UI change during dragged #601

gosongying opened this issue Sep 15, 2024 · 23 comments

Comments

@gosongying
Copy link

I am just wondering if a dragged item's UI will be changed when it is being dragged and a change to its content happens during dragging. Based on my experiment, it seems not. I am just curious. Thanks

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 15, 2024 via email

@gosongying
Copy link
Author

May I know how the cloning works? Because my item's content is dependant on a store, is that the reason the dragged item's UI is changed when I start dragging?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 16, 2024 via email

@gosongying
Copy link
Author

Ok, I will send you the REPL later. By the way, may I know what is id:dnd-shadow-placeholder-0000. It seems the item being dragged will have its id changed to this.

@gosongying
Copy link
Author

Can you explain what you mean by change? The drag element is cloned from the original element.

On Mon, Sep 16, 2024, 05:42 GO SONG YING @.> wrote: I am just wondering if a dragged item's UI will be changed when it is being dragged and a change to its content happens during dragging. Based on my experiment, it seems not. I am just curious. Thanks — Reply to this email directly, view it on GitHub <#601>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE4OZC6MRTD6MBY7JDN7MHDZWXPIVAVCNFSM6AAAAABOIC4SNGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZDOMJVHE3DINA . You are receiving this because you are subscribed to this thread.Message ID: @.>

The cloned node is re-rendered instead of reused right?

@gosongying
Copy link
Author

Hi, I’ve provided a simple REPL that reflects the situation in my project. While it's not an exact replica, it’s similar. My project uses Gridstack for managing child items, and the initialization of Gridstack can introduce delays in setting the full height of the items. The REPL simulates this by using setTimeout to increase the height after a delay.

The current issue is that when I start dragging an item, it might move outside of my cursor’s reach. I suspect this problem is related to the cloned item. The re-rendering of the item component takes some time, and if I drag it before the initialization is complete, the item might have a smaller height compared to the original, causing it to move away from the cursor.

Please let me know if anything is unclear. Thanks!
https://svelte.dev/repl/5c98ed11789f45c0a73346b2c241f7b7?version=4.2.19

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 16, 2024 via email

@gosongying
Copy link
Author

I might not get it HAHA. But what I mean is actually the initialization that happens when I drag the item (ps: correct me if I am wrong that there is an initialization happens when dragging happens), is the approach you suggested applicable for that?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 17, 2024 via email

@gosongying
Copy link
Author

Are you saying that the dragged item will not re-mount? It will just be the copy of the original element? If yes, why it does print out the message that I put in the onMount block?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 19, 2024 via email

@gosongying
Copy link
Author

Oh, I have just realised what you were saying. Now it works totally fine, thank you so much.

@gosongying
Copy link
Author

Just to clarify again, the original item will be re-created and put at the same place and occupy same space as it is, the dragged item is just a cloned of the original item? Is the original item being removed then?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 19, 2024 via email

@gosongying
Copy link
Author

Hi, I've created a REPL for Gridstack items, but I'm still facing an issue: when I start dragging an item from the top, the items below it suddenly drop down and bounce back. Additionally, the dragged item sometimes moves away from the cursor. Do you have any idea what could be causing this?

https://svelte.dev/repl/c7b6cb368b7945f095eb3794656944bf?version=4.2.19

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 21, 2024 via email

@gosongying
Copy link
Author

I'm working on a dynamic form project, and for array types, I'm utilizing your library to manage the reordering of items. Each item is essentially a Gridstack instance, which offers a smooth UI for making its inner content draggable.

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 21, 2024 via email

@gosongying
Copy link
Author

gosongying commented Sep 24, 2024

Hi, sorry for the late reply. That is so great, I can see that the item wont go out of the cursor. However, the issue still exists. Do you have any idea on that? Thank you so much.

when I start dragging an item from the top, the items below it suddenly drop down and bounce back

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 24, 2024 via email

@gosongying
Copy link
Author

I see, thanks for you help. By the way, I notice that the item that is being dragged will have its id becoming '"id:dnd-shadow-placeholder-0000', is this expected? As I am using the id to do some logic, that string make my logic fail, is it possible to get its original id back?

@isaacHagoel
Copy link
Owner

isaacHagoel commented Sep 29, 2024 via email

@gosongying
Copy link
Author

Oh I got it. My child component has relied on the id for some reason, I have resolved it, thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants