@souscheflabs/reanimated-flashlist 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hooks/drag/useDragGesture.d.ts.map +1 -1
- package/lib/hooks/drag/useDragGesture.js +2 -4
- package/lib/hooks/drag/useDragShift.js +5 -4
- package/lib/hooks/drag/useDropCompensation.d.ts.map +1 -1
- package/lib/hooks/drag/useDropCompensation.js +3 -4
- package/package.json +1 -1
- package/src/hooks/drag/useDragGesture.ts +2 -5
- package/src/hooks/drag/useDragShift.ts +5 -5
- package/src/hooks/drag/useDropCompensation.ts +3 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDragGesture.d.ts","sourceRoot":"","sources":["../../../src/hooks/drag/useDragGesture.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,uBAAuB,GACjC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useDragGesture.d.ts","sourceRoot":"","sources":["../../../src/hooks/drag/useDragGesture.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,oBAAoB,EAC5B,SAAS,EAAE,uBAAuB,GACjC,oBAAoB,CAoPtB"}
|
|
@@ -62,10 +62,8 @@ function useDragGesture(config, callbacks) {
|
|
|
62
62
|
// Calculate new position and call reorder callback
|
|
63
63
|
const handleDragEnd = (0, react_1.useCallback)((finalTranslateY) => {
|
|
64
64
|
const { index: currentIndex, totalItems: total, itemId: currentItemId, onReorderByDelta: reorder, } = dragContextRef.current;
|
|
65
|
-
// Use
|
|
66
|
-
const itemHeight =
|
|
67
|
-
? measuredItemHeight.value + dragConfig.itemVerticalMargin
|
|
68
|
-
: dragConfig.itemHeight;
|
|
65
|
+
// Use configured itemHeight for consistent position calculations
|
|
66
|
+
const itemHeight = dragConfig.itemHeight;
|
|
69
67
|
// Calculate how many positions to move based on drag offset
|
|
70
68
|
const positionDelta = Math.round(finalTranslateY / itemHeight);
|
|
71
69
|
// Calculate if position actually changes
|
|
@@ -48,10 +48,11 @@ function useDragShift(config) {
|
|
|
48
48
|
// If not dragging, reset to 0
|
|
49
49
|
if (!isDraggingNow)
|
|
50
50
|
return 0;
|
|
51
|
-
// Use
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// Use configured itemHeight for consistent shift calculations
|
|
52
|
+
// Note: Previously we used measuredItemHeight + margin, but this caused inconsistencies
|
|
53
|
+
// because measure() may or may not include child margins depending on the view hierarchy.
|
|
54
|
+
// The configured itemHeight (content + margins) provides reliable, predictable behavior.
|
|
55
|
+
const itemHeight = dragConfig.itemHeight;
|
|
55
56
|
// Calculate effective translateY including scroll delta
|
|
56
57
|
const scrollDelta = scrollOffset.value - dragStartScrollOffset.value;
|
|
57
58
|
const effectiveTranslateY = translateYNow + scrollDelta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDropCompensation.d.ts","sourceRoot":"","sources":["../../../src/hooks/drag/useDropCompensation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useDropCompensation.d.ts","sourceRoot":"","sources":["../../../src/hooks/drag/useDropCompensation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,yBAAyB,GAAG,IAAI,CAmG3E"}
|
|
@@ -48,10 +48,9 @@ function useDropCompensation(config) {
|
|
|
48
48
|
setPrevIndex(index);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
: dragConfig.itemHeight;
|
|
51
|
+
// Use configured itemHeight for consistent compensation calculations
|
|
52
|
+
// This matches useDragShift behavior for reliable, predictable positioning
|
|
53
|
+
const itemHeight = dragConfig.itemHeight;
|
|
55
54
|
// Compensate for index change by adjusting translateY
|
|
56
55
|
const indexDelta = index - prevIndex;
|
|
57
56
|
const heightDelta = indexDelta * itemHeight;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@souscheflabs/reanimated-flashlist",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "A high-performance animated FlashList with drag-to-reorder and entry/exit animations (New Architecture)",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -104,11 +104,8 @@ export function useDragGesture(
|
|
|
104
104
|
onReorderByDelta: reorder,
|
|
105
105
|
} = dragContextRef.current;
|
|
106
106
|
|
|
107
|
-
// Use
|
|
108
|
-
const itemHeight =
|
|
109
|
-
measuredItemHeight.value > 0
|
|
110
|
-
? measuredItemHeight.value + dragConfig.itemVerticalMargin
|
|
111
|
-
: dragConfig.itemHeight;
|
|
107
|
+
// Use configured itemHeight for consistent position calculations
|
|
108
|
+
const itemHeight = dragConfig.itemHeight;
|
|
112
109
|
|
|
113
110
|
// Calculate how many positions to move based on drag offset
|
|
114
111
|
const positionDelta = Math.round(finalTranslateY / itemHeight);
|
|
@@ -69,11 +69,11 @@ export function useDragShift(config: UseDragShiftConfig): UseDragShiftResult {
|
|
|
69
69
|
// If not dragging, reset to 0
|
|
70
70
|
if (!isDraggingNow) return 0;
|
|
71
71
|
|
|
72
|
-
// Use
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
// Use configured itemHeight for consistent shift calculations
|
|
73
|
+
// Note: Previously we used measuredItemHeight + margin, but this caused inconsistencies
|
|
74
|
+
// because measure() may or may not include child margins depending on the view hierarchy.
|
|
75
|
+
// The configured itemHeight (content + margins) provides reliable, predictable behavior.
|
|
76
|
+
const itemHeight = dragConfig.itemHeight;
|
|
77
77
|
|
|
78
78
|
// Calculate effective translateY including scroll delta
|
|
79
79
|
const scrollDelta = scrollOffset.value - dragStartScrollOffset.value;
|
|
@@ -64,11 +64,9 @@ export function useDropCompensation(config: UseDropCompensationConfig): void {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
? measuredItemHeight.value + dragConfig.itemVerticalMargin
|
|
71
|
-
: dragConfig.itemHeight;
|
|
67
|
+
// Use configured itemHeight for consistent compensation calculations
|
|
68
|
+
// This matches useDragShift behavior for reliable, predictable positioning
|
|
69
|
+
const itemHeight = dragConfig.itemHeight;
|
|
72
70
|
|
|
73
71
|
// Compensate for index change by adjusting translateY
|
|
74
72
|
const indexDelta = index - prevIndex;
|