@legendapp/list 1.0.0-beta.3 → 1.0.0-beta.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/index.d.mts +2 -3
- package/index.d.ts +2 -3
- package/index.js +52 -41
- package/index.mjs +52 -41
- package/package.json +1 -1
- package/reanimated.d.mts +4 -1
- package/reanimated.d.ts +4 -1
package/index.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ declare class ScrollAdjustHandler {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
19
|
-
data:
|
|
19
|
+
data: ReadonlyArray<ItemT>;
|
|
20
20
|
initialScrollOffset?: number;
|
|
21
21
|
initialScrollIndex?: number;
|
|
22
22
|
drawDistance?: number;
|
|
@@ -45,7 +45,6 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
|
|
|
45
45
|
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
46
46
|
ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
|
|
47
47
|
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
48
|
-
ListEmptyComponentStyle?: StyleProp<ViewStyle> | undefined;
|
|
49
48
|
ItemSeparatorComponent?: React.ComponentType<any>;
|
|
50
49
|
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
|
|
51
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
@@ -87,7 +86,7 @@ interface InternalState {
|
|
|
87
86
|
isEndReached: boolean;
|
|
88
87
|
isAtBottom: boolean;
|
|
89
88
|
isAtTop: boolean;
|
|
90
|
-
data: any[];
|
|
89
|
+
data: readonly any[];
|
|
91
90
|
idsInFirstRender: Set<string>;
|
|
92
91
|
hasScrolled: boolean;
|
|
93
92
|
scrollLength: number;
|
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare class ScrollAdjustHandler {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof Animated.ScrollView>> = Omit<TScrollView, 'contentOffset' | 'contentInset' | 'maintainVisibleContentPosition' | 'stickyHeaderIndices'> & {
|
|
19
|
-
data:
|
|
19
|
+
data: ReadonlyArray<ItemT>;
|
|
20
20
|
initialScrollOffset?: number;
|
|
21
21
|
initialScrollIndex?: number;
|
|
22
22
|
drawDistance?: number;
|
|
@@ -45,7 +45,6 @@ type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof Scroll
|
|
|
45
45
|
ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
46
46
|
ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
|
|
47
47
|
ListEmptyComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
|
|
48
|
-
ListEmptyComponentStyle?: StyleProp<ViewStyle> | undefined;
|
|
49
48
|
ItemSeparatorComponent?: React.ComponentType<any>;
|
|
50
49
|
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
|
|
51
50
|
viewabilityConfig?: ViewabilityConfig;
|
|
@@ -87,7 +86,7 @@ interface InternalState {
|
|
|
87
86
|
isEndReached: boolean;
|
|
88
87
|
isAtBottom: boolean;
|
|
89
88
|
isAtTop: boolean;
|
|
90
|
-
data: any[];
|
|
89
|
+
data: readonly any[];
|
|
91
90
|
idsInFirstRender: Set<string>;
|
|
92
91
|
hasScrolled: boolean;
|
|
93
92
|
scrollLength: number;
|
package/index.js
CHANGED
|
@@ -176,6 +176,7 @@ var ANCHORED_POSITION_OUT_OF_VIEW = {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
// src/Container.tsx
|
|
179
|
+
var isNewArchitecture = global.nativeFabricUIManager != null;
|
|
179
180
|
var Container = ({
|
|
180
181
|
id,
|
|
181
182
|
recycleItems,
|
|
@@ -184,7 +185,7 @@ var Container = ({
|
|
|
184
185
|
updateItemSize,
|
|
185
186
|
ItemSeparatorComponent
|
|
186
187
|
}) => {
|
|
187
|
-
|
|
188
|
+
useStateContext();
|
|
188
189
|
const maintainVisibleContentPosition = use$("maintainVisibleContentPosition");
|
|
189
190
|
const position = use$(`containerPosition${id}`) || ANCHORED_POSITION_OUT_OF_VIEW;
|
|
190
191
|
const column = use$(`containerColumn${id}`) || 0;
|
|
@@ -209,44 +210,36 @@ var Container = ({
|
|
|
209
210
|
const itemKey = use$(`containerItemKey${id}`);
|
|
210
211
|
const data = use$(`containerItemData${id}`);
|
|
211
212
|
const extraData = use$("extraData");
|
|
212
|
-
const refLastSize = React5.useRef();
|
|
213
213
|
const renderedItemInfo = React5.useMemo(
|
|
214
214
|
() => itemKey !== void 0 && getRenderedItem(itemKey),
|
|
215
215
|
[itemKey, data, extraData]
|
|
216
216
|
);
|
|
217
217
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
218
|
-
React5.useEffect(() => {
|
|
219
|
-
if (itemKey) {
|
|
220
|
-
const timeout = setTimeout(() => {
|
|
221
|
-
if (refLastSize.current) {
|
|
222
|
-
updateItemSize(id, itemKey, refLastSize.current);
|
|
223
|
-
}
|
|
224
|
-
}, 16);
|
|
225
|
-
return () => {
|
|
226
|
-
clearTimeout(timeout);
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}, [itemKey]);
|
|
230
218
|
const onLayout = (event) => {
|
|
231
|
-
|
|
232
|
-
if (key !== void 0) {
|
|
219
|
+
if (itemKey !== void 0) {
|
|
233
220
|
const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
|
|
234
|
-
|
|
221
|
+
if (size === 0) {
|
|
222
|
+
console.log("[WARN] Container 0 height reported, possible bug in LegendList", id, itemKey);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
updateItemSize(id, itemKey, size);
|
|
235
226
|
}
|
|
236
227
|
};
|
|
237
228
|
const ref = React5.useRef(null);
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
229
|
+
if (isNewArchitecture) {
|
|
230
|
+
React5.useLayoutEffect(() => {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
if (itemKey) {
|
|
233
|
+
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
234
|
+
if (measured) {
|
|
235
|
+
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
236
|
+
if (size) {
|
|
237
|
+
updateItemSize(id, itemKey, size);
|
|
238
|
+
}
|
|
246
239
|
}
|
|
247
240
|
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
241
|
+
}, [itemKey]);
|
|
242
|
+
}
|
|
250
243
|
const contextValue = React5.useMemo(
|
|
251
244
|
() => ({ containerId: id, itemKey, index, value: data }),
|
|
252
245
|
[id, itemKey, index, data]
|
|
@@ -254,7 +247,7 @@ var Container = ({
|
|
|
254
247
|
const contentFragment = /* @__PURE__ */ React5__namespace.default.createElement(React5__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React5__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItem && ItemSeparatorComponent && itemKey !== lastItemKey && ItemSeparatorComponent));
|
|
255
248
|
if (maintainVisibleContentPosition) {
|
|
256
249
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
257
|
-
return /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style
|
|
250
|
+
return /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment));
|
|
258
251
|
}
|
|
259
252
|
return /* @__PURE__ */ React5__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
260
253
|
};
|
|
@@ -330,7 +323,6 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
330
323
|
ListFooterComponent,
|
|
331
324
|
ListFooterComponentStyle,
|
|
332
325
|
ListEmptyComponent,
|
|
333
|
-
ListEmptyComponentStyle,
|
|
334
326
|
getRenderedItem,
|
|
335
327
|
updateItemSize,
|
|
336
328
|
refScrollView,
|
|
@@ -379,7 +371,7 @@ var ListComponent = React5__namespace.memo(function ListComponent2({
|
|
|
379
371
|
},
|
|
380
372
|
getComponent(ListHeaderComponent)
|
|
381
373
|
),
|
|
382
|
-
ListEmptyComponent &&
|
|
374
|
+
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
383
375
|
/* @__PURE__ */ React5__namespace.createElement(
|
|
384
376
|
Containers,
|
|
385
377
|
{
|
|
@@ -606,17 +598,22 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
606
598
|
renderItem,
|
|
607
599
|
estimatedItemSize,
|
|
608
600
|
getEstimatedItemSize,
|
|
609
|
-
onEndReached,
|
|
610
|
-
onStartReached,
|
|
611
601
|
ListEmptyComponent,
|
|
612
602
|
onItemSizeChanged,
|
|
613
603
|
scrollEventThrottle,
|
|
614
604
|
refScrollView,
|
|
615
605
|
waitForInitialLayout = true,
|
|
616
606
|
extraData,
|
|
607
|
+
onLayout: onLayoutProp,
|
|
617
608
|
...rest
|
|
618
609
|
} = props;
|
|
619
610
|
const { style, contentContainerStyle } = props;
|
|
611
|
+
const callbacks = React5.useRef({
|
|
612
|
+
onStartReached: rest.onStartReached,
|
|
613
|
+
onEndReached: rest.onEndReached
|
|
614
|
+
});
|
|
615
|
+
callbacks.current.onStartReached = rest.onStartReached;
|
|
616
|
+
callbacks.current.onEndReached = rest.onEndReached;
|
|
620
617
|
const ctx = useStateContext();
|
|
621
618
|
const refScroller = React5.useRef(null);
|
|
622
619
|
const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
|
|
@@ -736,7 +733,6 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
736
733
|
isAboveAnchor = true;
|
|
737
734
|
}
|
|
738
735
|
}
|
|
739
|
-
state.totalSize;
|
|
740
736
|
if (key === null) {
|
|
741
737
|
state.totalSize = add;
|
|
742
738
|
state.totalSizeBelowAnchor = totalSizeBelowAnchor;
|
|
@@ -837,7 +833,17 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
837
833
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
838
834
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
839
835
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
840
|
-
const scroll = scrollState - previousScrollAdjust - topPad
|
|
836
|
+
const scroll = scrollState - previousScrollAdjust - topPad;
|
|
837
|
+
let scrollBufferTop = scrollBuffer;
|
|
838
|
+
let scrollBufferBottom = scrollBuffer;
|
|
839
|
+
if (scrollExtra > 8) {
|
|
840
|
+
scrollBufferTop = 0;
|
|
841
|
+
scrollBufferBottom = scrollBuffer + scrollExtra;
|
|
842
|
+
}
|
|
843
|
+
if (scrollExtra < -8) {
|
|
844
|
+
scrollBufferTop = scrollBuffer - scrollExtra;
|
|
845
|
+
scrollBufferBottom = 0;
|
|
846
|
+
}
|
|
841
847
|
if (state.scrollForNextCalculateItemsInView) {
|
|
842
848
|
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
843
849
|
if (scroll > top2 && scroll < bottom) {
|
|
@@ -909,7 +915,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
909
915
|
if (startNoBuffer === null && top + size > scroll) {
|
|
910
916
|
startNoBuffer = i;
|
|
911
917
|
}
|
|
912
|
-
if (startBuffered === null && top + size > scroll -
|
|
918
|
+
if (startBuffered === null && top + size > scroll - scrollBufferTop) {
|
|
913
919
|
startBuffered = i;
|
|
914
920
|
startBufferedId = id;
|
|
915
921
|
}
|
|
@@ -917,7 +923,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
917
923
|
if (top <= scrollBottom) {
|
|
918
924
|
endNoBuffer = i;
|
|
919
925
|
}
|
|
920
|
-
if (top <= scrollBottom +
|
|
926
|
+
if (top <= scrollBottom + scrollBufferBottom) {
|
|
921
927
|
endBuffered = i;
|
|
922
928
|
} else {
|
|
923
929
|
break;
|
|
@@ -1095,6 +1101,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1095
1101
|
if (refState.current) {
|
|
1096
1102
|
refState.current.isAtBottom = distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
|
|
1097
1103
|
}
|
|
1104
|
+
const { onEndReached } = callbacks.current;
|
|
1098
1105
|
if (onEndReached) {
|
|
1099
1106
|
if (!refState.current.isEndReached) {
|
|
1100
1107
|
if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
|
|
@@ -1116,6 +1123,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1116
1123
|
const { scrollLength, scroll } = refState.current;
|
|
1117
1124
|
const distanceFromTop = scroll;
|
|
1118
1125
|
refState.current.isAtTop = distanceFromTop < 0;
|
|
1126
|
+
const { onStartReached } = callbacks.current;
|
|
1119
1127
|
if (onStartReached) {
|
|
1120
1128
|
if (!refState.current.isStartReached && !refState.current.startReachedBlockedByTimer) {
|
|
1121
1129
|
if (distanceFromTop < onStartReachedThreshold * scrollLength) {
|
|
@@ -1244,7 +1252,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1244
1252
|
set$(ctx, "extraData", extraData);
|
|
1245
1253
|
}, [extraData]);
|
|
1246
1254
|
refState.current.renderItem = renderItem;
|
|
1247
|
-
const lastItemKey = getId(data
|
|
1255
|
+
const lastItemKey = data.length > 0 ? getId(data.length - 1) : void 0;
|
|
1248
1256
|
const stylePaddingTop = (_e = (_d = (_b = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _b.paddingTop) != null ? _d : (_c = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _c.paddingTop) != null ? _e : 0;
|
|
1249
1257
|
const initalizeStateVars = () => {
|
|
1250
1258
|
set$(ctx, "lastItemKey", lastItemKey);
|
|
@@ -1397,6 +1405,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1397
1405
|
);
|
|
1398
1406
|
}
|
|
1399
1407
|
}
|
|
1408
|
+
if (onLayoutProp) {
|
|
1409
|
+
onLayoutProp(event);
|
|
1410
|
+
}
|
|
1400
1411
|
}, []);
|
|
1401
1412
|
const handleScroll = React5.useCallback(
|
|
1402
1413
|
(event, fromSelf) => {
|
|
@@ -1450,9 +1461,9 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1450
1461
|
};
|
|
1451
1462
|
return {
|
|
1452
1463
|
getNativeScrollRef: () => refScroller.current,
|
|
1453
|
-
getScrollableNode: refScroller.current.getScrollableNode,
|
|
1454
|
-
getScrollResponder: refScroller.current.getScrollResponder,
|
|
1455
|
-
flashScrollIndicators: refScroller.current.flashScrollIndicators,
|
|
1464
|
+
getScrollableNode: () => refScroller.current.getScrollableNode(),
|
|
1465
|
+
getScrollResponder: () => refScroller.current.getScrollResponder(),
|
|
1466
|
+
flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
|
|
1456
1467
|
scrollToIndex,
|
|
1457
1468
|
scrollToOffset: ({ offset, animated }) => {
|
|
1458
1469
|
const offsetObj = horizontal ? { x: offset, y: 0 } : { x: 0, y: offset };
|
|
@@ -1464,7 +1475,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1464
1475
|
scrollToIndex({ index, animated });
|
|
1465
1476
|
}
|
|
1466
1477
|
},
|
|
1467
|
-
scrollToEnd: refScroller.current.scrollToEnd
|
|
1478
|
+
scrollToEnd: () => refScroller.current.scrollToEnd()
|
|
1468
1479
|
};
|
|
1469
1480
|
},
|
|
1470
1481
|
[]
|
package/index.mjs
CHANGED
|
@@ -155,6 +155,7 @@ var ANCHORED_POSITION_OUT_OF_VIEW = {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
// src/Container.tsx
|
|
158
|
+
var isNewArchitecture = global.nativeFabricUIManager != null;
|
|
158
159
|
var Container = ({
|
|
159
160
|
id,
|
|
160
161
|
recycleItems,
|
|
@@ -163,7 +164,7 @@ var Container = ({
|
|
|
163
164
|
updateItemSize,
|
|
164
165
|
ItemSeparatorComponent
|
|
165
166
|
}) => {
|
|
166
|
-
|
|
167
|
+
useStateContext();
|
|
167
168
|
const maintainVisibleContentPosition = use$("maintainVisibleContentPosition");
|
|
168
169
|
const position = use$(`containerPosition${id}`) || ANCHORED_POSITION_OUT_OF_VIEW;
|
|
169
170
|
const column = use$(`containerColumn${id}`) || 0;
|
|
@@ -188,44 +189,36 @@ var Container = ({
|
|
|
188
189
|
const itemKey = use$(`containerItemKey${id}`);
|
|
189
190
|
const data = use$(`containerItemData${id}`);
|
|
190
191
|
const extraData = use$("extraData");
|
|
191
|
-
const refLastSize = useRef();
|
|
192
192
|
const renderedItemInfo = useMemo(
|
|
193
193
|
() => itemKey !== void 0 && getRenderedItem(itemKey),
|
|
194
194
|
[itemKey, data, extraData]
|
|
195
195
|
);
|
|
196
196
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
if (itemKey) {
|
|
199
|
-
const timeout = setTimeout(() => {
|
|
200
|
-
if (refLastSize.current) {
|
|
201
|
-
updateItemSize(id, itemKey, refLastSize.current);
|
|
202
|
-
}
|
|
203
|
-
}, 16);
|
|
204
|
-
return () => {
|
|
205
|
-
clearTimeout(timeout);
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}, [itemKey]);
|
|
209
197
|
const onLayout = (event) => {
|
|
210
|
-
|
|
211
|
-
if (key !== void 0) {
|
|
198
|
+
if (itemKey !== void 0) {
|
|
212
199
|
const size = Math.floor(event.nativeEvent.layout[horizontal ? "width" : "height"] * 8) / 8;
|
|
213
|
-
|
|
200
|
+
if (size === 0) {
|
|
201
|
+
console.log("[WARN] Container 0 height reported, possible bug in LegendList", id, itemKey);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
updateItemSize(id, itemKey, size);
|
|
214
205
|
}
|
|
215
206
|
};
|
|
216
207
|
const ref = useRef(null);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
208
|
+
if (isNewArchitecture) {
|
|
209
|
+
useLayoutEffect(() => {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
if (itemKey) {
|
|
212
|
+
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
213
|
+
if (measured) {
|
|
214
|
+
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
215
|
+
if (size) {
|
|
216
|
+
updateItemSize(id, itemKey, size);
|
|
217
|
+
}
|
|
225
218
|
}
|
|
226
219
|
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
220
|
+
}, [itemKey]);
|
|
221
|
+
}
|
|
229
222
|
const contextValue = useMemo(
|
|
230
223
|
() => ({ containerId: id, itemKey, index, value: data }),
|
|
231
224
|
[id, itemKey, index, data]
|
|
@@ -233,7 +226,7 @@ var Container = ({
|
|
|
233
226
|
const contentFragment = /* @__PURE__ */ React5__default.createElement(React5__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React5__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItem && ItemSeparatorComponent && itemKey !== lastItemKey && ItemSeparatorComponent));
|
|
234
227
|
if (maintainVisibleContentPosition) {
|
|
235
228
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
236
|
-
return /* @__PURE__ */ React5__default.createElement(LeanView, { style
|
|
229
|
+
return /* @__PURE__ */ React5__default.createElement(LeanView, { style }, /* @__PURE__ */ React5__default.createElement(LeanView, { style: anchorStyle, onLayout, ref }, contentFragment));
|
|
237
230
|
}
|
|
238
231
|
return /* @__PURE__ */ React5__default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
239
232
|
};
|
|
@@ -309,7 +302,6 @@ var ListComponent = React5.memo(function ListComponent2({
|
|
|
309
302
|
ListFooterComponent,
|
|
310
303
|
ListFooterComponentStyle,
|
|
311
304
|
ListEmptyComponent,
|
|
312
|
-
ListEmptyComponentStyle,
|
|
313
305
|
getRenderedItem,
|
|
314
306
|
updateItemSize,
|
|
315
307
|
refScrollView,
|
|
@@ -358,7 +350,7 @@ var ListComponent = React5.memo(function ListComponent2({
|
|
|
358
350
|
},
|
|
359
351
|
getComponent(ListHeaderComponent)
|
|
360
352
|
),
|
|
361
|
-
ListEmptyComponent &&
|
|
353
|
+
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
362
354
|
/* @__PURE__ */ React5.createElement(
|
|
363
355
|
Containers,
|
|
364
356
|
{
|
|
@@ -585,17 +577,22 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
585
577
|
renderItem,
|
|
586
578
|
estimatedItemSize,
|
|
587
579
|
getEstimatedItemSize,
|
|
588
|
-
onEndReached,
|
|
589
|
-
onStartReached,
|
|
590
580
|
ListEmptyComponent,
|
|
591
581
|
onItemSizeChanged,
|
|
592
582
|
scrollEventThrottle,
|
|
593
583
|
refScrollView,
|
|
594
584
|
waitForInitialLayout = true,
|
|
595
585
|
extraData,
|
|
586
|
+
onLayout: onLayoutProp,
|
|
596
587
|
...rest
|
|
597
588
|
} = props;
|
|
598
589
|
const { style, contentContainerStyle } = props;
|
|
590
|
+
const callbacks = useRef({
|
|
591
|
+
onStartReached: rest.onStartReached,
|
|
592
|
+
onEndReached: rest.onEndReached
|
|
593
|
+
});
|
|
594
|
+
callbacks.current.onStartReached = rest.onStartReached;
|
|
595
|
+
callbacks.current.onEndReached = rest.onEndReached;
|
|
599
596
|
const ctx = useStateContext();
|
|
600
597
|
const refScroller = useRef(null);
|
|
601
598
|
const scrollBuffer = drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE;
|
|
@@ -715,7 +712,6 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
715
712
|
isAboveAnchor = true;
|
|
716
713
|
}
|
|
717
714
|
}
|
|
718
|
-
state.totalSize;
|
|
719
715
|
if (key === null) {
|
|
720
716
|
state.totalSize = add;
|
|
721
717
|
state.totalSizeBelowAnchor = totalSizeBelowAnchor;
|
|
@@ -816,7 +812,17 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
816
812
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
817
813
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
818
814
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
819
|
-
const scroll = scrollState - previousScrollAdjust - topPad
|
|
815
|
+
const scroll = scrollState - previousScrollAdjust - topPad;
|
|
816
|
+
let scrollBufferTop = scrollBuffer;
|
|
817
|
+
let scrollBufferBottom = scrollBuffer;
|
|
818
|
+
if (scrollExtra > 8) {
|
|
819
|
+
scrollBufferTop = 0;
|
|
820
|
+
scrollBufferBottom = scrollBuffer + scrollExtra;
|
|
821
|
+
}
|
|
822
|
+
if (scrollExtra < -8) {
|
|
823
|
+
scrollBufferTop = scrollBuffer - scrollExtra;
|
|
824
|
+
scrollBufferBottom = 0;
|
|
825
|
+
}
|
|
820
826
|
if (state.scrollForNextCalculateItemsInView) {
|
|
821
827
|
const { top: top2, bottom } = state.scrollForNextCalculateItemsInView;
|
|
822
828
|
if (scroll > top2 && scroll < bottom) {
|
|
@@ -888,7 +894,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
888
894
|
if (startNoBuffer === null && top + size > scroll) {
|
|
889
895
|
startNoBuffer = i;
|
|
890
896
|
}
|
|
891
|
-
if (startBuffered === null && top + size > scroll -
|
|
897
|
+
if (startBuffered === null && top + size > scroll - scrollBufferTop) {
|
|
892
898
|
startBuffered = i;
|
|
893
899
|
startBufferedId = id;
|
|
894
900
|
}
|
|
@@ -896,7 +902,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
896
902
|
if (top <= scrollBottom) {
|
|
897
903
|
endNoBuffer = i;
|
|
898
904
|
}
|
|
899
|
-
if (top <= scrollBottom +
|
|
905
|
+
if (top <= scrollBottom + scrollBufferBottom) {
|
|
900
906
|
endBuffered = i;
|
|
901
907
|
} else {
|
|
902
908
|
break;
|
|
@@ -1074,6 +1080,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1074
1080
|
if (refState.current) {
|
|
1075
1081
|
refState.current.isAtBottom = distanceFromEnd < scrollLength * maintainScrollAtEndThreshold;
|
|
1076
1082
|
}
|
|
1083
|
+
const { onEndReached } = callbacks.current;
|
|
1077
1084
|
if (onEndReached) {
|
|
1078
1085
|
if (!refState.current.isEndReached) {
|
|
1079
1086
|
if (distanceFromEnd < onEndReachedThreshold * scrollLength) {
|
|
@@ -1095,6 +1102,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1095
1102
|
const { scrollLength, scroll } = refState.current;
|
|
1096
1103
|
const distanceFromTop = scroll;
|
|
1097
1104
|
refState.current.isAtTop = distanceFromTop < 0;
|
|
1105
|
+
const { onStartReached } = callbacks.current;
|
|
1098
1106
|
if (onStartReached) {
|
|
1099
1107
|
if (!refState.current.isStartReached && !refState.current.startReachedBlockedByTimer) {
|
|
1100
1108
|
if (distanceFromTop < onStartReachedThreshold * scrollLength) {
|
|
@@ -1223,7 +1231,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1223
1231
|
set$(ctx, "extraData", extraData);
|
|
1224
1232
|
}, [extraData]);
|
|
1225
1233
|
refState.current.renderItem = renderItem;
|
|
1226
|
-
const lastItemKey = getId(data
|
|
1234
|
+
const lastItemKey = data.length > 0 ? getId(data.length - 1) : void 0;
|
|
1227
1235
|
const stylePaddingTop = (_e = (_d = (_b = StyleSheet.flatten(style)) == null ? void 0 : _b.paddingTop) != null ? _d : (_c = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _c.paddingTop) != null ? _e : 0;
|
|
1228
1236
|
const initalizeStateVars = () => {
|
|
1229
1237
|
set$(ctx, "lastItemKey", lastItemKey);
|
|
@@ -1376,6 +1384,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1376
1384
|
);
|
|
1377
1385
|
}
|
|
1378
1386
|
}
|
|
1387
|
+
if (onLayoutProp) {
|
|
1388
|
+
onLayoutProp(event);
|
|
1389
|
+
}
|
|
1379
1390
|
}, []);
|
|
1380
1391
|
const handleScroll = useCallback(
|
|
1381
1392
|
(event, fromSelf) => {
|
|
@@ -1429,9 +1440,9 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1429
1440
|
};
|
|
1430
1441
|
return {
|
|
1431
1442
|
getNativeScrollRef: () => refScroller.current,
|
|
1432
|
-
getScrollableNode: refScroller.current.getScrollableNode,
|
|
1433
|
-
getScrollResponder: refScroller.current.getScrollResponder,
|
|
1434
|
-
flashScrollIndicators: refScroller.current.flashScrollIndicators,
|
|
1443
|
+
getScrollableNode: () => refScroller.current.getScrollableNode(),
|
|
1444
|
+
getScrollResponder: () => refScroller.current.getScrollResponder(),
|
|
1445
|
+
flashScrollIndicators: () => refScroller.current.flashScrollIndicators(),
|
|
1435
1446
|
scrollToIndex,
|
|
1436
1447
|
scrollToOffset: ({ offset, animated }) => {
|
|
1437
1448
|
const offsetObj = horizontal ? { x: offset, y: 0 } : { x: 0, y: offset };
|
|
@@ -1443,7 +1454,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1443
1454
|
scrollToIndex({ index, animated });
|
|
1444
1455
|
}
|
|
1445
1456
|
},
|
|
1446
|
-
scrollToEnd: refScroller.current.scrollToEnd
|
|
1457
|
+
scrollToEnd: () => refScroller.current.scrollToEnd()
|
|
1447
1458
|
};
|
|
1448
1459
|
},
|
|
1449
1460
|
[]
|
package/package.json
CHANGED
package/reanimated.d.mts
CHANGED
|
@@ -8,6 +8,9 @@ interface AnimatedLegendListProps<ItemT> extends Omit<PropsBase<ItemT>, KeysToOm
|
|
|
8
8
|
refScrollView?: react__default.Ref<Animated.ScrollView>;
|
|
9
9
|
}
|
|
10
10
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
|
-
|
|
11
|
+
type AnimatedLegendListDefinition = <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "refLegendList"> & OtherAnimatedLegendListProps<ItemT> & {
|
|
12
|
+
ref?: react__default.Ref<LegendListRef>;
|
|
13
|
+
}) => react__default.ReactElement | null;
|
|
14
|
+
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
12
15
|
|
|
13
16
|
export { AnimatedLegendList };
|
package/reanimated.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ interface AnimatedLegendListProps<ItemT> extends Omit<PropsBase<ItemT>, KeysToOm
|
|
|
8
8
|
refScrollView?: react__default.Ref<Animated.ScrollView>;
|
|
9
9
|
}
|
|
10
10
|
type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
|
|
11
|
-
|
|
11
|
+
type AnimatedLegendListDefinition = <ItemT>(props: Omit<AnimatedLegendListProps<ItemT>, "refLegendList"> & OtherAnimatedLegendListProps<ItemT> & {
|
|
12
|
+
ref?: react__default.Ref<LegendListRef>;
|
|
13
|
+
}) => react__default.ReactElement | null;
|
|
14
|
+
declare const AnimatedLegendList: AnimatedLegendListDefinition;
|
|
12
15
|
|
|
13
16
|
export { AnimatedLegendList };
|