Commit Graph

18 Commits

Author SHA1 Message Date
Philip Su
9985a70a36
chore: Upgrade Android example app's RN (#82)
Got things building and running again.
2025-03-08 01:57:10 -08:00
Philip Su
18aea700f2
chore: fix README.md type in example code (#77) 2025-03-05 15:04:12 -08:00
Philip Su
9fc6126b0d
fix: #70 Timing fix for async measure call (#73)
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.
2025-01-16 16:33:26 -08:00
Philip Su
eb65cf8860
fix: #68 - forwardRef declaration (#71)
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).
2025-01-14 18:20:10 -08:00
Philip Su
53ef42bedd
feat: #40 Allow custom FlatList prop (#62)
* feat: Allow replacing FlatList component via prop

* tiny fixes

* integrated RN types

* renamed and added documentation

* type conformity

---------

Co-authored-by: Kavanaugh Latiolais <kav@pelo.tech>
2024-12-01 06:32:58 -05:00
Philip Su
4defc7a929
fix: #53 - Active item animation rendering for RN 0.76.3 (#54)
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.
2024-11-29 16:28:58 -08:00
Philip Su
9de6d19c26
fix: #40 - remove LayoutAnimation related code (#47)
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.
2024-08-17 15:22:24 -07:00
Philip Su
7cbd958fbd
feat: make scrolling axis-generic and update README.md (#36) 2024-03-17 17:13:51 -07:00
Philip Su
3918204c14 fix: block rapid reordering from using stale indices
Not sure this is absolutely necessary, but it prevents people from rapidly reordering things so quickly that stale indices are used.
2024-03-16 19:01:52 -07:00
Philip Su
410451b941
fix: update y position upon panResponderGrant to capture list position on screen
onLayout is not sent during moves, only during resizes, and so we need to update the y position to the latest whenever you begin dragging.
2023-06-21 14:27:56 -07:00
Philip Su
4438944f75 feat: rename onStartDrag to onDragStart and onEndDrag to onDragEnd #17
Made this backward compatible so that existing clients aren't broken, but have also marked the old functions deprecated.
2023-06-16 14:48:59 -07:00
Philip Su
e5820361d1 fix: update y position upon panResponderGrant in order to capture new list position
onLayout is not sent during moves, only during resizes, and so we need to update the y position to the latest whenever you begin dragging.
2023-06-13 16:28:17 -07:00
Philip Su
8174553c15 wip: demo that onLayout is called when parent resizes 2023-06-12 14:40:11 -07:00
Philip Su
5d5db67774 feat: provide forwardRef for callers to access the underlying FlatList
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.
2023-06-06 14:15:19 -07:00
Philip Su
c6ad49f3cb fix: deactivate item when press happens without drag
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.
2023-03-31 13:46:41 -07:00
Philip Su
eb5acfe4d5 fix: Android now works 2023-01-23 11:03:11 -08:00
Philip Su
e244f39374 Fixed inclusion of parent in example project 2022-12-15 16:58:27 -08:00
Philip Su
a528f08134 Initial example building 2022-12-15 16:58:23 -08:00