Not positive this fixes#70, but there's at least one issue, which is
that `measure()` calls its callback asynchronously, so some values
relied on in several of the panResponder functions are incorrect if you
perform them prior to the measurement being complete.
In particular, for #70, it's likely `grantActiveCenterOffsetRef.current`
that ends up incorrect if you blow past the `measure()` too quickly.
This PR:
- Adds a `flatWrapRefPosUpdatedRef` to track whether the `measure()`
callback has been called.
- Moves the `grantActiveCenterOffsetRef` calculation to after the
`measure()` callback has been called.
- Skips processing onPanResponderMove if the `measure()` callback hasn't
been called yet.
Removed the forwardRef declaration from the index.tsx and instead used a
different approach to propagate types past the forwardRef (which
otherwise removes the type inference/binding based on the data prop).
Starting somewhere near RN 0.76.3, using `Animated.setValue()` on the actively dragged item no longer moves its position. I don't understand why, and looked a while on the internet. I suspect that things like `Animated.timing()` give you a chance to twiddle `useNativeDriver`, so using those calls might now be necessary.
Anyway, the fix was empirically derived. We now properly animate dragged objects again in the latest RN.
Had to upgrade the example project to RN 0.76.3 as part of this.
React Native docs say Android needs this experimental flag to be on if you use LayoutAnimation, but we don't. It had been causing some crashes, so here's the fix.
We do this by keeping a ref ourselves (which we always needed to support auto-scrolling as you drag) as well as exposing a copy of the ref out to the caller through forwardRef.
In previous versions, if you press but don't drag, DragList never
captures the panhandler -- in which case it can't know when you've
released. This caused items to be rendered as `isActive` even after
release if you press and release without moving. We now introduce
`onDragEnd`, which you should call during your component's `onPressOut`.
By doing this, active items will be correctly marked inactive as soon as
you release even if you haven't moved.