@legendapp/list 1.0.11 → 1.0.12
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/CHANGELOG.md +10 -0
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/index.js +195 -155
- package/index.mjs +147 -107
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React3 from 'react';
|
|
2
|
+
import React3__default, { useReducer, useEffect, createContext, useMemo, useRef, useCallback, useImperativeHandle, useContext, useState, forwardRef, memo, useLayoutEffect } from 'react';
|
|
3
3
|
import { View, Text, Platform, Animated, ScrollView, StyleSheet, Dimensions, RefreshControl } from 'react-native';
|
|
4
4
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
5
5
|
|
|
6
6
|
// src/LegendList.tsx
|
|
7
|
-
var ContextState =
|
|
7
|
+
var ContextState = React3.createContext(null);
|
|
8
8
|
function StateProvider({ children }) {
|
|
9
|
-
const [value] =
|
|
9
|
+
const [value] = React3.useState(() => ({
|
|
10
10
|
listeners: /* @__PURE__ */ new Map(),
|
|
11
11
|
values: /* @__PURE__ */ new Map([
|
|
12
12
|
["paddingTop", 0],
|
|
@@ -21,10 +21,10 @@ function StateProvider({ children }) {
|
|
|
21
21
|
columnWrapperStyle: void 0,
|
|
22
22
|
viewRefs: /* @__PURE__ */ new Map()
|
|
23
23
|
}));
|
|
24
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ React3.createElement(ContextState.Provider, { value }, children);
|
|
25
25
|
}
|
|
26
26
|
function useStateContext() {
|
|
27
|
-
return
|
|
27
|
+
return React3.useContext(ContextState);
|
|
28
28
|
}
|
|
29
29
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
30
30
|
let lastValues = [];
|
|
@@ -94,17 +94,17 @@ function getContentSize(ctx) {
|
|
|
94
94
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
95
95
|
}
|
|
96
96
|
function useArr$(signalNames) {
|
|
97
|
-
const ctx =
|
|
98
|
-
const { subscribe, get } =
|
|
97
|
+
const ctx = React3.useContext(ContextState);
|
|
98
|
+
const { subscribe, get } = React3.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
99
99
|
const value = useSyncExternalStore(subscribe, get);
|
|
100
100
|
return value;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// src/DebugView.tsx
|
|
104
104
|
var DebugRow = ({ children }) => {
|
|
105
|
-
return /* @__PURE__ */
|
|
105
|
+
return /* @__PURE__ */ React3.createElement(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
|
|
106
106
|
};
|
|
107
|
-
var DebugView =
|
|
107
|
+
var DebugView = React3.memo(function DebugView2({ state }) {
|
|
108
108
|
const ctx = useStateContext();
|
|
109
109
|
const [
|
|
110
110
|
totalSize = 0,
|
|
@@ -128,7 +128,7 @@ var DebugView = React2.memo(function DebugView2({ state }) {
|
|
|
128
128
|
useInterval(() => {
|
|
129
129
|
forceUpdate();
|
|
130
130
|
}, 100);
|
|
131
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ React3.createElement(
|
|
132
132
|
View,
|
|
133
133
|
{
|
|
134
134
|
style: {
|
|
@@ -144,15 +144,15 @@ var DebugView = React2.memo(function DebugView2({ state }) {
|
|
|
144
144
|
},
|
|
145
145
|
pointerEvents: "none"
|
|
146
146
|
},
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React3.createElement(Text, null, totalSize.toFixed(2))),
|
|
148
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React3.createElement(Text, null, contentSize.toFixed(2))),
|
|
149
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "At end:"), /* @__PURE__ */ React3.createElement(Text, null, String(state.isAtBottom))),
|
|
150
|
+
/* @__PURE__ */ React3.createElement(Text, null),
|
|
151
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React3.createElement(Text, null, scrollAdjust.toFixed(2))),
|
|
152
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "TotalSizeReal: "), /* @__PURE__ */ React3.createElement(Text, null, totalSizeWithScrollAdjust.toFixed(2))),
|
|
153
|
+
/* @__PURE__ */ React3.createElement(Text, null),
|
|
154
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React3.createElement(Text, null, rawScroll.toFixed(2))),
|
|
155
|
+
/* @__PURE__ */ React3.createElement(DebugRow, null, /* @__PURE__ */ React3.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React3.createElement(Text, null, scroll.toFixed(2)))
|
|
156
156
|
);
|
|
157
157
|
});
|
|
158
158
|
function useInterval(callback, delay) {
|
|
@@ -280,8 +280,8 @@ function useRecyclingState(valueOrFun) {
|
|
|
280
280
|
);
|
|
281
281
|
return [refState.current.value, setState];
|
|
282
282
|
}
|
|
283
|
-
var LeanViewComponent =
|
|
284
|
-
return
|
|
283
|
+
var LeanViewComponent = React3.forwardRef((props, ref) => {
|
|
284
|
+
return React3.createElement("RCTView", { ...props, ref });
|
|
285
285
|
});
|
|
286
286
|
LeanViewComponent.displayName = "RCTView";
|
|
287
287
|
var LeanView = Platform.OS === "android" || Platform.OS === "ios" ? LeanViewComponent : View;
|
|
@@ -421,16 +421,16 @@ var Container = ({
|
|
|
421
421
|
ctx.viewRefs.set(id, ref);
|
|
422
422
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
423
423
|
}, [id, itemKey, index, data]);
|
|
424
|
-
const contentFragment = /* @__PURE__ */
|
|
424
|
+
const contentFragment = /* @__PURE__ */ React3__default.createElement(React3__default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React3__default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React3__default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
425
425
|
if (maintainVisibleContentPosition) {
|
|
426
426
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
427
427
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
428
428
|
anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
|
|
429
429
|
anchorStyle.borderWidth = 1;
|
|
430
430
|
}
|
|
431
|
-
return /* @__PURE__ */
|
|
431
|
+
return /* @__PURE__ */ React3__default.createElement(LeanView, { style }, /* @__PURE__ */ React3__default.createElement(LeanView, { style: [anchorStyle, paddingStyles], onLayout, ref }, contentFragment, __DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React3__default.createElement(Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
|
|
432
432
|
}
|
|
433
|
-
return /* @__PURE__ */
|
|
433
|
+
return /* @__PURE__ */ React3__default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
434
434
|
};
|
|
435
435
|
var typedForwardRef = forwardRef;
|
|
436
436
|
var typedMemo = memo;
|
|
@@ -483,7 +483,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
483
483
|
const containers = [];
|
|
484
484
|
for (let i = 0; i < numContainers; i++) {
|
|
485
485
|
containers.push(
|
|
486
|
-
/* @__PURE__ */
|
|
486
|
+
/* @__PURE__ */ React3.createElement(
|
|
487
487
|
Container,
|
|
488
488
|
{
|
|
489
489
|
id: i,
|
|
@@ -512,16 +512,41 @@ var Containers = typedMemo(function Containers2({
|
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
-
return /* @__PURE__ */
|
|
515
|
+
return /* @__PURE__ */ React3.createElement(Animated.View, { style }, containers);
|
|
516
516
|
});
|
|
517
|
+
function ListHeaderComponentContainer({
|
|
518
|
+
children,
|
|
519
|
+
style,
|
|
520
|
+
ctx,
|
|
521
|
+
horizontal,
|
|
522
|
+
waitForInitialLayout
|
|
523
|
+
}) {
|
|
524
|
+
const scrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
525
|
+
const animOpacity = waitForInitialLayout ? useValue$("containersDidLayout", (value) => value ? 1 : 0) : void 0;
|
|
526
|
+
const additionalSize = {
|
|
527
|
+
transform: [{ translateY: Animated.multiply(scrollAdjust, -1) }],
|
|
528
|
+
opacity: animOpacity
|
|
529
|
+
};
|
|
530
|
+
return /* @__PURE__ */ React.createElement(
|
|
531
|
+
Animated.View,
|
|
532
|
+
{
|
|
533
|
+
style: [style, additionalSize],
|
|
534
|
+
onLayout: (event) => {
|
|
535
|
+
const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
536
|
+
set$(ctx, "headerSize", size);
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
children
|
|
540
|
+
);
|
|
541
|
+
}
|
|
517
542
|
|
|
518
543
|
// src/ListComponent.tsx
|
|
519
544
|
var getComponent = (Component) => {
|
|
520
|
-
if (
|
|
545
|
+
if (React3.isValidElement(Component)) {
|
|
521
546
|
return Component;
|
|
522
547
|
}
|
|
523
548
|
if (Component) {
|
|
524
|
-
return /* @__PURE__ */
|
|
549
|
+
return /* @__PURE__ */ React3.createElement(Component, null);
|
|
525
550
|
}
|
|
526
551
|
return null;
|
|
527
552
|
};
|
|
@@ -529,12 +554,12 @@ var PaddingAndAdjust = () => {
|
|
|
529
554
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
530
555
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
531
556
|
const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
|
|
532
|
-
return /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ React3.createElement(Animated.View, { style: additionalSize });
|
|
533
558
|
};
|
|
534
559
|
var PaddingAndAdjustDevMode = () => {
|
|
535
560
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
536
561
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
537
|
-
return /* @__PURE__ */
|
|
562
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React3.createElement(Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React3.createElement(
|
|
538
563
|
Animated.View,
|
|
539
564
|
{
|
|
540
565
|
style: {
|
|
@@ -546,7 +571,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
546
571
|
backgroundColor: "green"
|
|
547
572
|
}
|
|
548
573
|
}
|
|
549
|
-
), /* @__PURE__ */
|
|
574
|
+
), /* @__PURE__ */ React3.createElement(
|
|
550
575
|
Animated.View,
|
|
551
576
|
{
|
|
552
577
|
style: {
|
|
@@ -558,7 +583,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
558
583
|
backgroundColor: "lightblue"
|
|
559
584
|
}
|
|
560
585
|
}
|
|
561
|
-
), /* @__PURE__ */
|
|
586
|
+
), /* @__PURE__ */ React3.createElement(
|
|
562
587
|
Animated.View,
|
|
563
588
|
{
|
|
564
589
|
style: {
|
|
@@ -604,10 +629,10 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
604
629
|
}) {
|
|
605
630
|
const ctx = useStateContext();
|
|
606
631
|
const ScrollComponent = renderScrollComponent ? useMemo(
|
|
607
|
-
() =>
|
|
632
|
+
() => React3.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
608
633
|
[renderScrollComponent]
|
|
609
634
|
) : ScrollView;
|
|
610
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ React3.createElement(
|
|
611
636
|
ScrollComponent,
|
|
612
637
|
{
|
|
613
638
|
...rest,
|
|
@@ -625,20 +650,19 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
625
650
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
626
651
|
ref: refScrollView
|
|
627
652
|
},
|
|
628
|
-
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */
|
|
629
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
630
|
-
|
|
653
|
+
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React3.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React3.createElement(PaddingAndAdjust, null)),
|
|
654
|
+
ListHeaderComponent && /* @__PURE__ */ React3.createElement(
|
|
655
|
+
ListHeaderComponentContainer,
|
|
631
656
|
{
|
|
632
657
|
style: ListHeaderComponentStyle,
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
658
|
+
ctx,
|
|
659
|
+
horizontal,
|
|
660
|
+
waitForInitialLayout
|
|
637
661
|
},
|
|
638
662
|
getComponent(ListHeaderComponent)
|
|
639
663
|
),
|
|
640
664
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
641
|
-
/* @__PURE__ */
|
|
665
|
+
/* @__PURE__ */ React3.createElement(
|
|
642
666
|
Containers,
|
|
643
667
|
{
|
|
644
668
|
horizontal,
|
|
@@ -649,7 +673,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
649
673
|
updateItemSize
|
|
650
674
|
}
|
|
651
675
|
),
|
|
652
|
-
ListFooterComponent && /* @__PURE__ */
|
|
676
|
+
ListFooterComponent && /* @__PURE__ */ React3.createElement(
|
|
653
677
|
View,
|
|
654
678
|
{
|
|
655
679
|
style: ListFooterComponentStyle,
|
|
@@ -931,7 +955,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
931
955
|
}
|
|
932
956
|
}
|
|
933
957
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
934
|
-
return /* @__PURE__ */
|
|
958
|
+
return /* @__PURE__ */ React3.createElement(StateProvider, null, /* @__PURE__ */ React3.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
935
959
|
});
|
|
936
960
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
937
961
|
const {
|
|
@@ -1051,7 +1075,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1051
1075
|
offset = index * estimatedItemSize;
|
|
1052
1076
|
}
|
|
1053
1077
|
const adjust = peek$(ctx, "containersDidLayout") ? ((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0 : 0;
|
|
1054
|
-
|
|
1078
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1079
|
+
return offset / numColumnsProp - adjust + topPad;
|
|
1055
1080
|
}
|
|
1056
1081
|
return 0;
|
|
1057
1082
|
};
|
|
@@ -1084,6 +1109,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1084
1109
|
scrollPrev: 0,
|
|
1085
1110
|
scrollPrevTime: 0,
|
|
1086
1111
|
scrollTime: 0,
|
|
1112
|
+
scrollPending: 0,
|
|
1087
1113
|
indexByKey: /* @__PURE__ */ new Map(),
|
|
1088
1114
|
scrollHistory: [],
|
|
1089
1115
|
scrollVelocity: 0,
|
|
@@ -1152,11 +1178,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1152
1178
|
const firstIndexOffset = calculateOffsetForIndex(index);
|
|
1153
1179
|
let firstIndexScrollPostion = firstIndexOffset - viewOffset;
|
|
1154
1180
|
const diff = Math.abs(state.scroll - firstIndexScrollPostion);
|
|
1181
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1155
1182
|
const needsReanchoring = maintainVisibleContentPosition && diff > 100;
|
|
1156
1183
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
1157
1184
|
if (needsReanchoring) {
|
|
1158
1185
|
const id = getId(index);
|
|
1159
|
-
state.anchorElement = { id, coordinate: firstIndexOffset };
|
|
1186
|
+
state.anchorElement = { id, coordinate: firstIndexOffset - topPad };
|
|
1160
1187
|
(_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1161
1188
|
state.positions.clear();
|
|
1162
1189
|
calcTotalSizesAndPositions({ forgetPositions: true });
|
|
@@ -1276,6 +1303,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1276
1303
|
state.scrollHistory.length = 0;
|
|
1277
1304
|
setTimeout(() => {
|
|
1278
1305
|
state.disableScrollJumpsFrom = void 0;
|
|
1306
|
+
if (state.scrollPending !== void 0 && state.scrollPending !== state.scroll) {
|
|
1307
|
+
updateScroll(state.scrollPending);
|
|
1308
|
+
}
|
|
1279
1309
|
}, timeout);
|
|
1280
1310
|
}
|
|
1281
1311
|
};
|
|
@@ -1389,7 +1419,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1389
1419
|
const numColumns = peek$(ctx, "numColumns");
|
|
1390
1420
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1391
1421
|
let scrollState = state.scroll;
|
|
1392
|
-
const scrollExtra =
|
|
1422
|
+
const scrollExtra = 0;
|
|
1393
1423
|
const useAverageSize = !state.disableScrollJumpsFrom && speed >= 0 && peek$(ctx, "containersDidLayout");
|
|
1394
1424
|
if (!state.queuedInitialLayout && initialScrollIndex) {
|
|
1395
1425
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
@@ -1698,6 +1728,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1698
1728
|
if (paddingTop > 0) {
|
|
1699
1729
|
state.scroll = 0;
|
|
1700
1730
|
}
|
|
1731
|
+
state.disableScrollJumpsFrom = void 0;
|
|
1701
1732
|
requestAnimationFrame(() => {
|
|
1702
1733
|
var _a;
|
|
1703
1734
|
state.maintainingScrollAtEnd = true;
|
|
@@ -1787,8 +1818,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1787
1818
|
if (state) {
|
|
1788
1819
|
state.data = dataProp;
|
|
1789
1820
|
if (!isFirst2) {
|
|
1790
|
-
|
|
1791
|
-
|
|
1821
|
+
const totalSizeBefore = state.previousTotalSize;
|
|
1822
|
+
const totalSizeAfter = state.totalSize;
|
|
1823
|
+
const scrollDiff = state.scroll - state.scrollPrev;
|
|
1824
|
+
const sizeDiff = totalSizeAfter - totalSizeBefore;
|
|
1825
|
+
if (Math.abs(scrollDiff - sizeDiff) < 10) {
|
|
1826
|
+
disableScrollJumps(1e3);
|
|
1827
|
+
}
|
|
1792
1828
|
const numContainers = peek$(ctx, "numContainers");
|
|
1793
1829
|
for (let i = 0; i < numContainers; i++) {
|
|
1794
1830
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
@@ -1999,6 +2035,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1999
2035
|
refState.current.sizes.clear();
|
|
2000
2036
|
refState.current.positions.clear();
|
|
2001
2037
|
}
|
|
2038
|
+
refState.current.previousTotalSize = peek$(ctx, "totalSize");
|
|
2002
2039
|
calcTotalSizesAndPositions({ forgetPositions: false });
|
|
2003
2040
|
}
|
|
2004
2041
|
useEffect(() => {
|
|
@@ -2206,73 +2243,76 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2206
2243
|
}
|
|
2207
2244
|
}, []);
|
|
2208
2245
|
const handleScroll = useCallback(
|
|
2209
|
-
(event
|
|
2246
|
+
(event) => {
|
|
2210
2247
|
var _a, _b, _c, _d;
|
|
2211
2248
|
if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
2212
2249
|
return;
|
|
2213
2250
|
}
|
|
2214
2251
|
const state = refState.current;
|
|
2215
|
-
const scrollingToOffset = state.scrollingToOffset;
|
|
2216
2252
|
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
2253
|
+
state.scrollPending = newScroll;
|
|
2217
2254
|
if (state.ignoreScrollFromCalcTotal && newScroll !== 0) {
|
|
2218
2255
|
return;
|
|
2219
2256
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2257
|
+
updateScroll(newScroll);
|
|
2258
|
+
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
2259
|
+
},
|
|
2260
|
+
[]
|
|
2261
|
+
);
|
|
2262
|
+
const updateScroll = useCallback((newScroll) => {
|
|
2263
|
+
const state = refState.current;
|
|
2264
|
+
const scrollingToOffset = state.scrollingToOffset;
|
|
2265
|
+
if (scrollingToOffset !== void 0 && Math.abs(newScroll - scrollingToOffset) < 10) {
|
|
2266
|
+
finishScrollTo();
|
|
2267
|
+
}
|
|
2268
|
+
if (state.disableScrollJumpsFrom !== void 0) {
|
|
2269
|
+
const scrollMinusAdjust = newScroll - state.scrollAdjustHandler.getAppliedAdjust();
|
|
2270
|
+
if (Math.abs(scrollMinusAdjust - state.disableScrollJumpsFrom) > 200) {
|
|
2271
|
+
return;
|
|
2229
2272
|
}
|
|
2230
|
-
state.
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
state.scrollTimer
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
if (oldest) {
|
|
2257
|
-
const scrollDiff = newest.scroll - oldest.scroll;
|
|
2258
|
-
const timeDiff = newest.time - oldest.time;
|
|
2259
|
-
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
2273
|
+
state.disableScrollJumpsFrom = void 0;
|
|
2274
|
+
}
|
|
2275
|
+
state.hasScrolled = true;
|
|
2276
|
+
state.lastBatchingAction = Date.now();
|
|
2277
|
+
const currentTime = performance.now();
|
|
2278
|
+
if (scrollingToOffset === void 0 && !(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
2279
|
+
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2280
|
+
}
|
|
2281
|
+
if (state.scrollHistory.length > 5) {
|
|
2282
|
+
state.scrollHistory.shift();
|
|
2283
|
+
}
|
|
2284
|
+
if (state.scrollTimer !== void 0) {
|
|
2285
|
+
clearTimeout(state.scrollTimer);
|
|
2286
|
+
}
|
|
2287
|
+
state.scrollTimer = setTimeout(() => {
|
|
2288
|
+
state.scrollVelocity = 0;
|
|
2289
|
+
}, 500);
|
|
2290
|
+
let velocity = 0;
|
|
2291
|
+
if (state.scrollHistory.length >= 2) {
|
|
2292
|
+
const newest = state.scrollHistory[state.scrollHistory.length - 1];
|
|
2293
|
+
let oldest;
|
|
2294
|
+
for (let i = 0; i < state.scrollHistory.length - 1; i++) {
|
|
2295
|
+
const entry = state.scrollHistory[i];
|
|
2296
|
+
if (newest.time - entry.time <= 100) {
|
|
2297
|
+
oldest = entry;
|
|
2298
|
+
break;
|
|
2260
2299
|
}
|
|
2261
2300
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
state.scrollVelocity = velocity;
|
|
2267
|
-
calculateItemsInView();
|
|
2268
|
-
checkAtBottom();
|
|
2269
|
-
checkAtTop();
|
|
2270
|
-
if (!fromSelf) {
|
|
2271
|
-
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
2301
|
+
if (oldest) {
|
|
2302
|
+
const scrollDiff = newest.scroll - oldest.scroll;
|
|
2303
|
+
const timeDiff = newest.time - oldest.time;
|
|
2304
|
+
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
2272
2305
|
}
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
|
|
2306
|
+
}
|
|
2307
|
+
state.scrollPrev = state.scroll;
|
|
2308
|
+
state.scrollPrevTime = state.scrollTime;
|
|
2309
|
+
state.scroll = newScroll;
|
|
2310
|
+
state.scrollTime = currentTime;
|
|
2311
|
+
state.scrollVelocity = velocity;
|
|
2312
|
+
calculateItemsInView();
|
|
2313
|
+
checkAtBottom();
|
|
2314
|
+
checkAtTop();
|
|
2315
|
+
}, []);
|
|
2276
2316
|
useImperativeHandle(
|
|
2277
2317
|
forwardedRef,
|
|
2278
2318
|
() => {
|
|
@@ -2346,7 +2386,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2346
2386
|
}
|
|
2347
2387
|
}, []);
|
|
2348
2388
|
}
|
|
2349
|
-
return /* @__PURE__ */
|
|
2389
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
2350
2390
|
ListComponent,
|
|
2351
2391
|
{
|
|
2352
2392
|
...rest,
|
|
@@ -2385,7 +2425,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2385
2425
|
maintainVisibleContentPosition,
|
|
2386
2426
|
scrollEventThrottle: Platform.OS === "web" ? 16 : void 0,
|
|
2387
2427
|
waitForInitialLayout,
|
|
2388
|
-
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */
|
|
2428
|
+
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React3.createElement(
|
|
2389
2429
|
RefreshControl,
|
|
2390
2430
|
{
|
|
2391
2431
|
refreshing: !!refreshing,
|
|
@@ -2396,7 +2436,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2396
2436
|
style,
|
|
2397
2437
|
contentContainerStyle
|
|
2398
2438
|
}
|
|
2399
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
2439
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3.createElement(DebugView, { state: refState.current }));
|
|
2400
2440
|
});
|
|
2401
2441
|
|
|
2402
2442
|
export { LegendList, useRecyclingEffect, useRecyclingState, useViewability, useViewabilityAmount };
|
package/package.json
CHANGED