nuclearpasta / react-native-drax

A drag-and-drop system for React Native
MIT License
554 stars 69 forks source link

Drop position relative to scroll #106

Closed haswalt closed 3 years ago

haswalt commented 3 years ago

In a simple example i'm using a DraxScrollView to provide audo scrolling of a large horizontally scrolling DraxView so that in the app items can be dragged offscreen and positioned within the DraxScrollView.

The onReceiveDragDrop gives me the absolute position which I'm currently using to position items within the long DraxView, hoever this means after scrolling the items are positioned only with the first screen bounds.

Is there something on the DraxScrollView event data or similar that gives me the position of the drop with the scroll being taken into account?

lafiosca commented 3 years ago

Off the top of my head I would say I don't think that data is exposed. Did you close this because you intend on working around it with the scrollRef, per your PR #107 ?

haswalt commented 3 years ago

Well turns out it’s as simple as tracking onScroll and using contentOffset plus the absolute drop coordinates.

My Pr is to allow making calls like scrollTo on the child scrollView.

Incidentally it would be nice if the drop coordinates maybe had a relative drop alongside the absolute that took into account the contentOffset internally