tajo / react-movable

🔀 Drag and drop for your React lists and tables. Accessible. Tiny.
https://react-movable.pages.dev
MIT License
1.55k stars 51 forks source link

Expose more events #20

Closed danbriggs5 closed 4 years ago

danbriggs5 commented 5 years ago

I appreciate your focus on minimalism and sticking to just the essentials! It's a great library. I'm wondering if any of the following additions would make the cut to be added?

  1. onDragEnd event that fires regardless of whether a change occurs or not. I'm using beforeDrag to track when dragging is actually occurring and customizing the UI. But I need custom logic to determine when it stops.
  2. Send the clientX and clientY positions as part of the beforeDrag event.
  3. onMove event that includes clientX and clientY. I think 2&3 would allow for greater customization without adding any bulk to the library. Personally, I'd like to use 2&3 to change the cursor to a grabber only once the item has been dragged > 5px. Why? Because it's clickable until it's been dragged a few pixels (similar to Trello drag and drop).
tajo commented 5 years ago

I am open to this. Agreed that this doesn't add any bulk to the library; however, it increases the API surface so not taking this lightly.

  1. Would it be called after or before onChange? Why? Maybe it should be called afterDrag to pair with beforeDrag?
  2. onChange now returns targetRect (superset of clientX and clientY), so ideally we could return the same thing in all these events.
  3. That's a good use-case that I left out initially, so I'm fine with adding that. Would onMove interact with keyboard shortcuts?

Willing to open a PR, update the documentation and add some tests? :)

EternallLight commented 5 years ago

Hi @tajo I've watched your talk at React Advanced London and thereby found this project. You've done very cool job! Mind if I take this issue?

tajo commented 5 years ago

@EternallLight sure, thanks!

PManager1 commented 4 years ago

Any update on this ?

tajo commented 4 years ago

There doesn't seem to be much traction / strong need. Closing for now. Happy to discuss additions later if people have good use-cases.