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

Event for drag-starting #156

Closed
domhaas opened this issue Oct 21, 2022 · 4 comments
Closed

Event for drag-starting #156

domhaas opened this issue Oct 21, 2022 · 4 comments
Assignees

Comments

@domhaas
Copy link

domhaas commented Oct 21, 2022

Hey,

I could not find an "onStartDrag"-event when the user started dragging an item.
Background: I want to highlight possible drop-targets between two trees when the user starts dragging.

Any clue on this, or is this feature simply missing?

Thanks in advance.

Cheers,
Dom

@lukasbach
Copy link
Owner

Hi Dom.

Yeah, there are no direct hooks exposed to register for drag start events. But there are two other ways to hook into these kinds of event handlers yourself:

  • Custom interaction managers: You can use a custom interaction manager to customize the event handlers that are mounted to the item component. You can extend existing modes, so you can fairly easily add only the hook you need on top of existing event handlers.
  • Custom render logic: This would be more effort and something I wouldn't recommend just for this, but you can also customize the render logic for tree items and mount the event there.

@domhaas
Copy link
Author

domhaas commented Oct 22, 2022

Hey Lukas,

thank you for the clue.
As I'm already using the blueprintjs-renderers I successfully got access to all what I need in the right place.

Anyhow - I think it would not hurt to make the useDragAndDrop Hook available. What do you mean?

Btw when canReorderItems is set isDraggingOver from context is set to true - but when moving away from the item while dragging, it is not set to false. I think this might be a design-issue, as the item is already attached to the parent.

Thanks!

Cheers,
Dom

@lukasbach
Copy link
Owner

Hey @domhaas,

the useDragAndDrop hook just exposes the drag and drop context, which is already publically exposed through the environment ref: https://rct.lukasbach.com/docs/api/interfaces/TreeEnvironmentRef/#draganddropcontext

Regarding the isDraggingOver not being reset: Do you have steps how to reproduce this issue? For me, this property seems to correctly reset at least on the storybook playground.

rct-draggingover

@domhaas
Copy link
Author

domhaas commented Nov 2, 2022

Thank you very much @lukasbach
I think the issue with the isDraggingOver property was coming somewhere else. I will come back to the issue if I stumble again over it.

Cheers,
Dom

@domhaas domhaas closed this as completed Nov 2, 2022
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