@shopify/flash-list 2.0.0-rc.3 → 2.0.0-rc.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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/recyclerview/RecyclerView.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerView.js +20 -5
- package/dist/recyclerview/RecyclerView.js.map +1 -1
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts +37 -3
- package/dist/recyclerview/RecyclerViewContextProvider.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewContextProvider.js +4 -0
- package/dist/recyclerview/RecyclerViewContextProvider.js.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts +3 -1
- package/dist/recyclerview/RecyclerViewManager.d.ts.map +1 -1
- package/dist/recyclerview/RecyclerViewManager.js +12 -3
- package/dist/recyclerview/RecyclerViewManager.js.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useRecyclerViewController.js +19 -14
- package/dist/recyclerview/hooks/useRecyclerViewController.js.map +1 -1
- package/dist/recyclerview/hooks/useUnmountFlag.d.ts.map +1 -1
- package/dist/recyclerview/hooks/useUnmountFlag.js +1 -0
- package/dist/recyclerview/hooks/useUnmountFlag.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/recyclerview/RecyclerView.tsx +19 -6
- package/src/recyclerview/RecyclerViewContextProvider.ts +42 -3
- package/src/recyclerview/RecyclerViewManager.ts +10 -4
- package/src/recyclerview/hooks/useRecyclerViewController.tsx +16 -6
- package/src/recyclerview/hooks/useUnmountFlag.ts +1 -0
|
@@ -51,7 +51,7 @@ export function useRecyclerViewController<T>(
|
|
|
51
51
|
const [_, setRenderId] = useState(0);
|
|
52
52
|
const pauseOffsetCorrection = useRef(false);
|
|
53
53
|
const initialScrollCompletedRef = useRef(false);
|
|
54
|
-
const lastDataLengthRef = useRef(recyclerViewManager.
|
|
54
|
+
const lastDataLengthRef = useRef(recyclerViewManager.getDataLength());
|
|
55
55
|
const { setTimeout } = useUnmountAwareTimeout();
|
|
56
56
|
|
|
57
57
|
// Track the first visible item for maintaining scroll position
|
|
@@ -91,7 +91,12 @@ export function useRecyclerViewController<T>(
|
|
|
91
91
|
|
|
92
92
|
const computeFirstVisibleIndexForOffsetCorrection = useCallback(() => {
|
|
93
93
|
const { data, keyExtractor } = recyclerViewManager.props;
|
|
94
|
-
if (
|
|
94
|
+
if (
|
|
95
|
+
recyclerViewManager.getIsFirstLayoutComplete() &&
|
|
96
|
+
keyExtractor &&
|
|
97
|
+
recyclerViewManager.getDataLength() > 0 &&
|
|
98
|
+
recyclerViewManager.shouldMaintainVisibleContentPosition()
|
|
99
|
+
) {
|
|
95
100
|
// Update the tracked first visible item
|
|
96
101
|
const firstVisibleIndex = Math.max(
|
|
97
102
|
0,
|
|
@@ -123,7 +128,7 @@ export function useRecyclerViewController<T>(
|
|
|
123
128
|
pendingScrollCallbacks.current = [];
|
|
124
129
|
callbacks.forEach((callback) => callback());
|
|
125
130
|
|
|
126
|
-
const currentDataLength =
|
|
131
|
+
const currentDataLength = recyclerViewManager.getDataLength();
|
|
127
132
|
|
|
128
133
|
if (
|
|
129
134
|
recyclerViewManager.getIsFirstLayoutComplete() &&
|
|
@@ -162,7 +167,11 @@ export function useRecyclerViewController<T>(
|
|
|
162
167
|
firstVisibleItemLayout.current = {
|
|
163
168
|
...recyclerViewManager.getLayout(currentIndexOfFirstVisibleItem),
|
|
164
169
|
};
|
|
165
|
-
if (
|
|
170
|
+
if (
|
|
171
|
+
diff !== 0 &&
|
|
172
|
+
!pauseOffsetCorrection.current &&
|
|
173
|
+
!recyclerViewManager.animationOptimizationsEnabled
|
|
174
|
+
) {
|
|
166
175
|
// console.log("diff", diff, firstVisibleItemKey.current);
|
|
167
176
|
if (PlatformConfig.supportsOffsetCorrection) {
|
|
168
177
|
// console.log("scrollBy", diff);
|
|
@@ -195,7 +204,7 @@ export function useRecyclerViewController<T>(
|
|
|
195
204
|
|
|
196
205
|
computeFirstVisibleIndexForOffsetCorrection();
|
|
197
206
|
}
|
|
198
|
-
lastDataLengthRef.current =
|
|
207
|
+
lastDataLengthRef.current = recyclerViewManager.getDataLength();
|
|
199
208
|
}, [
|
|
200
209
|
recyclerViewManager,
|
|
201
210
|
scrollAnchorRef,
|
|
@@ -381,6 +390,7 @@ export function useRecyclerViewController<T>(
|
|
|
381
390
|
const performScrollStep = (currentStep: number) => {
|
|
382
391
|
// Check if component is unmounted or we've completed all steps
|
|
383
392
|
if (isUnmounted.current) {
|
|
393
|
+
resolve();
|
|
384
394
|
return;
|
|
385
395
|
} else if (currentStep >= steps) {
|
|
386
396
|
// All steps completed, perform final scroll
|
|
@@ -537,7 +547,7 @@ export function useRecyclerViewController<T>(
|
|
|
537
547
|
* Disables item recycling in preparation for layout animations.
|
|
538
548
|
*/
|
|
539
549
|
prepareForLayoutAnimationRender: () => {
|
|
540
|
-
recyclerViewManager.
|
|
550
|
+
recyclerViewManager.animationOptimizationsEnabled = true;
|
|
541
551
|
},
|
|
542
552
|
};
|
|
543
553
|
}, [
|
|
@@ -16,6 +16,7 @@ export const useUnmountFlag = () => {
|
|
|
16
16
|
// Use layoutEffect to set up cleanup on unmount
|
|
17
17
|
// This ensures the flag is set before any other cleanup effects run
|
|
18
18
|
useLayoutEffect(() => {
|
|
19
|
+
isUnmounted.current = false;
|
|
19
20
|
// Cleanup function that runs when the component unmounts
|
|
20
21
|
return () => {
|
|
21
22
|
isUnmounted.current = true;
|