@legendapp/list 1.0.10 → 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 +193 -142
- package/index.mjs +145 -94
- package/keyboard-controller.d.mts +133 -133
- package/keyboard-controller.d.ts +133 -133
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React3 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var shim = require('use-sync-external-store/shim');
|
|
6
6
|
|
|
@@ -22,12 +22,12 @@ function _interopNamespace(e) {
|
|
|
22
22
|
return Object.freeze(n);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
var
|
|
25
|
+
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
26
26
|
|
|
27
27
|
// src/LegendList.tsx
|
|
28
|
-
var ContextState =
|
|
28
|
+
var ContextState = React3__namespace.createContext(null);
|
|
29
29
|
function StateProvider({ children }) {
|
|
30
|
-
const [value] =
|
|
30
|
+
const [value] = React3__namespace.useState(() => ({
|
|
31
31
|
listeners: /* @__PURE__ */ new Map(),
|
|
32
32
|
values: /* @__PURE__ */ new Map([
|
|
33
33
|
["paddingTop", 0],
|
|
@@ -42,10 +42,10 @@ function StateProvider({ children }) {
|
|
|
42
42
|
columnWrapperStyle: void 0,
|
|
43
43
|
viewRefs: /* @__PURE__ */ new Map()
|
|
44
44
|
}));
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ React3__namespace.createElement(ContextState.Provider, { value }, children);
|
|
46
46
|
}
|
|
47
47
|
function useStateContext() {
|
|
48
|
-
return
|
|
48
|
+
return React3__namespace.useContext(ContextState);
|
|
49
49
|
}
|
|
50
50
|
function createSelectorFunctionsArr(ctx, signalNames) {
|
|
51
51
|
let lastValues = [];
|
|
@@ -115,17 +115,17 @@ function getContentSize(ctx) {
|
|
|
115
115
|
return headerSize + footerSize + totalSize + stylePaddingTop;
|
|
116
116
|
}
|
|
117
117
|
function useArr$(signalNames) {
|
|
118
|
-
const ctx =
|
|
119
|
-
const { subscribe, get } =
|
|
118
|
+
const ctx = React3__namespace.useContext(ContextState);
|
|
119
|
+
const { subscribe, get } = React3__namespace.useMemo(() => createSelectorFunctionsArr(ctx, signalNames), [ctx, signalNames]);
|
|
120
120
|
const value = shim.useSyncExternalStore(subscribe, get);
|
|
121
121
|
return value;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// src/DebugView.tsx
|
|
125
125
|
var DebugRow = ({ children }) => {
|
|
126
|
-
return /* @__PURE__ */
|
|
126
|
+
return /* @__PURE__ */ React3__namespace.createElement(reactNative.View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between" } }, children);
|
|
127
127
|
};
|
|
128
|
-
var DebugView =
|
|
128
|
+
var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
129
129
|
const ctx = useStateContext();
|
|
130
130
|
const [
|
|
131
131
|
totalSize = 0,
|
|
@@ -145,11 +145,11 @@ var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
|
145
145
|
"numContainersPooled"
|
|
146
146
|
]);
|
|
147
147
|
const contentSize = getContentSize(ctx);
|
|
148
|
-
const [, forceUpdate] =
|
|
148
|
+
const [, forceUpdate] = React3.useReducer((x) => x + 1, 0);
|
|
149
149
|
useInterval(() => {
|
|
150
150
|
forceUpdate();
|
|
151
151
|
}, 100);
|
|
152
|
-
return /* @__PURE__ */
|
|
152
|
+
return /* @__PURE__ */ React3__namespace.createElement(
|
|
153
153
|
reactNative.View,
|
|
154
154
|
{
|
|
155
155
|
style: {
|
|
@@ -165,19 +165,19 @@ var DebugView = React2__namespace.memo(function DebugView2({ state }) {
|
|
|
165
165
|
},
|
|
166
166
|
pointerEvents: "none"
|
|
167
167
|
},
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "TotalSize:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, totalSize.toFixed(2))),
|
|
169
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ContentSize:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, contentSize.toFixed(2))),
|
|
170
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "At end:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, String(state.isAtBottom))),
|
|
171
|
+
/* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null),
|
|
172
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ScrollAdjust:"), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, scrollAdjust.toFixed(2))),
|
|
173
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "TotalSizeReal: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, totalSizeWithScrollAdjust.toFixed(2))),
|
|
174
|
+
/* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null),
|
|
175
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
|
|
176
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, scroll.toFixed(2)))
|
|
177
177
|
);
|
|
178
178
|
});
|
|
179
179
|
function useInterval(callback, delay) {
|
|
180
|
-
|
|
180
|
+
React3.useEffect(() => {
|
|
181
181
|
const interval = setInterval(callback, delay);
|
|
182
182
|
return () => clearInterval(interval);
|
|
183
183
|
}, [delay]);
|
|
@@ -208,7 +208,7 @@ function comparatorDefault(a, b) {
|
|
|
208
208
|
}
|
|
209
209
|
var symbolFirst = Symbol();
|
|
210
210
|
function useInit(cb) {
|
|
211
|
-
const refValue =
|
|
211
|
+
const refValue = React3.useRef(symbolFirst);
|
|
212
212
|
if (refValue.current === symbolFirst) {
|
|
213
213
|
refValue.current = cb();
|
|
214
214
|
}
|
|
@@ -216,10 +216,10 @@ function useInit(cb) {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// src/ContextContainer.ts
|
|
219
|
-
var ContextContainer =
|
|
219
|
+
var ContextContainer = React3.createContext(null);
|
|
220
220
|
function useViewability(callback, configId) {
|
|
221
221
|
const ctx = useStateContext();
|
|
222
|
-
const { containerId } =
|
|
222
|
+
const { containerId } = React3.useContext(ContextContainer);
|
|
223
223
|
const key = containerId + (configId != null ? configId : "");
|
|
224
224
|
useInit(() => {
|
|
225
225
|
const value = ctx.mapViewabilityValues.get(key);
|
|
@@ -228,7 +228,7 @@ function useViewability(callback, configId) {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
ctx.mapViewabilityCallbacks.set(key, callback);
|
|
231
|
-
|
|
231
|
+
React3.useEffect(
|
|
232
232
|
() => () => {
|
|
233
233
|
ctx.mapViewabilityCallbacks.delete(key);
|
|
234
234
|
},
|
|
@@ -237,7 +237,7 @@ function useViewability(callback, configId) {
|
|
|
237
237
|
}
|
|
238
238
|
function useViewabilityAmount(callback) {
|
|
239
239
|
const ctx = useStateContext();
|
|
240
|
-
const { containerId } =
|
|
240
|
+
const { containerId } = React3.useContext(ContextContainer);
|
|
241
241
|
useInit(() => {
|
|
242
242
|
const value = ctx.mapViewabilityAmountValues.get(containerId);
|
|
243
243
|
if (value) {
|
|
@@ -245,7 +245,7 @@ function useViewabilityAmount(callback) {
|
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
ctx.mapViewabilityAmountCallbacks.set(containerId, callback);
|
|
248
|
-
|
|
248
|
+
React3.useEffect(
|
|
249
249
|
() => () => {
|
|
250
250
|
ctx.mapViewabilityAmountCallbacks.delete(containerId);
|
|
251
251
|
},
|
|
@@ -253,12 +253,12 @@ function useViewabilityAmount(callback) {
|
|
|
253
253
|
);
|
|
254
254
|
}
|
|
255
255
|
function useRecyclingEffect(effect) {
|
|
256
|
-
const { index, value } =
|
|
257
|
-
const prevValues =
|
|
256
|
+
const { index, value } = React3.useContext(ContextContainer);
|
|
257
|
+
const prevValues = React3.useRef({
|
|
258
258
|
prevIndex: void 0,
|
|
259
259
|
prevItem: void 0
|
|
260
260
|
});
|
|
261
|
-
|
|
261
|
+
React3.useEffect(() => {
|
|
262
262
|
let ret = void 0;
|
|
263
263
|
if (prevValues.current.prevIndex !== void 0 && prevValues.current.prevItem !== void 0) {
|
|
264
264
|
ret = effect({
|
|
@@ -276,12 +276,12 @@ function useRecyclingEffect(effect) {
|
|
|
276
276
|
}, [index, value]);
|
|
277
277
|
}
|
|
278
278
|
function useRecyclingState(valueOrFun) {
|
|
279
|
-
const { index, value, itemKey, triggerLayout } =
|
|
280
|
-
const refState =
|
|
279
|
+
const { index, value, itemKey, triggerLayout } = React3.useContext(ContextContainer);
|
|
280
|
+
const refState = React3.useRef({
|
|
281
281
|
itemKey: null,
|
|
282
282
|
value: null
|
|
283
283
|
});
|
|
284
|
-
const [_, setRenderNum] =
|
|
284
|
+
const [_, setRenderNum] = React3.useState(0);
|
|
285
285
|
if (refState.current.itemKey !== itemKey) {
|
|
286
286
|
refState.current.itemKey = itemKey;
|
|
287
287
|
refState.current.value = isFunction(valueOrFun) ? valueOrFun({
|
|
@@ -291,7 +291,7 @@ function useRecyclingState(valueOrFun) {
|
|
|
291
291
|
prevItem: void 0
|
|
292
292
|
}) : valueOrFun;
|
|
293
293
|
}
|
|
294
|
-
const setState =
|
|
294
|
+
const setState = React3.useCallback(
|
|
295
295
|
(newState) => {
|
|
296
296
|
refState.current.value = isFunction(newState) ? newState(refState.current.value) : newState;
|
|
297
297
|
setRenderNum((v) => v + 1);
|
|
@@ -301,8 +301,8 @@ function useRecyclingState(valueOrFun) {
|
|
|
301
301
|
);
|
|
302
302
|
return [refState.current.value, setState];
|
|
303
303
|
}
|
|
304
|
-
var LeanViewComponent =
|
|
305
|
-
return
|
|
304
|
+
var LeanViewComponent = React3__namespace.forwardRef((props, ref) => {
|
|
305
|
+
return React3__namespace.createElement("RCTView", { ...props, ref });
|
|
306
306
|
});
|
|
307
307
|
LeanViewComponent.displayName = "RCTView";
|
|
308
308
|
var LeanView = reactNative.Platform.OS === "android" || reactNative.Platform.OS === "ios" ? LeanViewComponent : reactNative.View;
|
|
@@ -348,9 +348,9 @@ var Container = ({
|
|
|
348
348
|
`containerItemData${id}`,
|
|
349
349
|
"extraData"
|
|
350
350
|
]);
|
|
351
|
-
const refLastSize =
|
|
352
|
-
const ref =
|
|
353
|
-
const [layoutRenderCount, forceLayoutRender] =
|
|
351
|
+
const refLastSize = React3.useRef();
|
|
352
|
+
const ref = React3.useRef(null);
|
|
353
|
+
const [layoutRenderCount, forceLayoutRender] = React3.useState(0);
|
|
354
354
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
355
355
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
356
356
|
let paddingStyles;
|
|
@@ -384,12 +384,12 @@ var Container = ({
|
|
|
384
384
|
top: position.relativeCoordinate,
|
|
385
385
|
...paddingStyles || {}
|
|
386
386
|
};
|
|
387
|
-
const renderedItemInfo =
|
|
387
|
+
const renderedItemInfo = React3.useMemo(
|
|
388
388
|
() => itemKey !== void 0 ? getRenderedItem(itemKey) : null,
|
|
389
389
|
[itemKey, data, extraData]
|
|
390
390
|
);
|
|
391
391
|
const { index, renderedItem } = renderedItemInfo || {};
|
|
392
|
-
const triggerLayout =
|
|
392
|
+
const triggerLayout = React3.useCallback(() => {
|
|
393
393
|
forceLayoutRender((v) => v + 1);
|
|
394
394
|
}, []);
|
|
395
395
|
const onLayout = (event) => {
|
|
@@ -412,7 +412,7 @@ var Container = ({
|
|
|
412
412
|
}
|
|
413
413
|
};
|
|
414
414
|
if (IsNewArchitecture) {
|
|
415
|
-
|
|
415
|
+
React3.useLayoutEffect(() => {
|
|
416
416
|
var _a, _b;
|
|
417
417
|
if (!isNullOrUndefined(itemKey)) {
|
|
418
418
|
const measured = (_b = (_a = ref.current) == null ? void 0 : _a.unstable_getBoundingClientRect) == null ? void 0 : _b.call(_a);
|
|
@@ -425,7 +425,7 @@ var Container = ({
|
|
|
425
425
|
}
|
|
426
426
|
}, [itemKey, layoutRenderCount]);
|
|
427
427
|
} else {
|
|
428
|
-
|
|
428
|
+
React3.useEffect(() => {
|
|
429
429
|
if (!isNullOrUndefined(itemKey)) {
|
|
430
430
|
const timeout = setTimeout(() => {
|
|
431
431
|
if (refLastSize.current) {
|
|
@@ -438,25 +438,25 @@ var Container = ({
|
|
|
438
438
|
}
|
|
439
439
|
}, [itemKey]);
|
|
440
440
|
}
|
|
441
|
-
const contextValue =
|
|
441
|
+
const contextValue = React3.useMemo(() => {
|
|
442
442
|
ctx.viewRefs.set(id, ref);
|
|
443
443
|
return { containerId: id, itemKey, index, value: data, triggerLayout };
|
|
444
444
|
}, [id, itemKey, index, data]);
|
|
445
|
-
const contentFragment = /* @__PURE__ */
|
|
445
|
+
const contentFragment = /* @__PURE__ */ React3__namespace.default.createElement(React3__namespace.default.Fragment, { key: recycleItems ? void 0 : itemKey }, /* @__PURE__ */ React3__namespace.default.createElement(ContextContainer.Provider, { value: contextValue }, renderedItem, renderedItemInfo && ItemSeparatorComponent && !lastItemKeys.includes(itemKey) && /* @__PURE__ */ React3__namespace.default.createElement(ItemSeparatorComponent, { leadingItem: renderedItemInfo.item })));
|
|
446
446
|
if (maintainVisibleContentPosition) {
|
|
447
447
|
const anchorStyle = position.type === "top" ? { position: "absolute", top: 0, left: 0, right: 0 } : { position: "absolute", bottom: 0, left: 0, right: 0 };
|
|
448
448
|
if (__DEV__ && ENABLE_DEVMODE) {
|
|
449
449
|
anchorStyle.borderColor = position.type === "top" ? "red" : "blue";
|
|
450
450
|
anchorStyle.borderWidth = 1;
|
|
451
451
|
}
|
|
452
|
-
return /* @__PURE__ */
|
|
452
|
+
return /* @__PURE__ */ React3__namespace.default.createElement(LeanView, { style }, /* @__PURE__ */ React3__namespace.default.createElement(LeanView, { style: [anchorStyle, paddingStyles], onLayout, ref }, contentFragment, __DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React3__namespace.default.createElement(reactNative.Text, { style: { position: "absolute", top: 0, left: 0, zIndex: 1e3 } }, position.top)));
|
|
453
453
|
}
|
|
454
|
-
return /* @__PURE__ */
|
|
454
|
+
return /* @__PURE__ */ React3__namespace.default.createElement(LeanView, { style, onLayout, ref }, contentFragment);
|
|
455
455
|
};
|
|
456
|
-
var typedForwardRef =
|
|
457
|
-
var typedMemo =
|
|
456
|
+
var typedForwardRef = React3.forwardRef;
|
|
457
|
+
var typedMemo = React3.memo;
|
|
458
458
|
var useAnimatedValue = (initialValue) => {
|
|
459
|
-
return
|
|
459
|
+
return React3.useRef(new reactNative.Animated.Value(initialValue)).current;
|
|
460
460
|
};
|
|
461
461
|
|
|
462
462
|
// src/useValue$.ts
|
|
@@ -464,7 +464,7 @@ function useValue$(key, getValue, useMicrotask) {
|
|
|
464
464
|
var _a;
|
|
465
465
|
const ctx = useStateContext();
|
|
466
466
|
const animValue = useAnimatedValue((_a = getValue ? getValue(peek$(ctx, key)) : peek$(ctx, key)) != null ? _a : 0);
|
|
467
|
-
|
|
467
|
+
React3.useMemo(() => {
|
|
468
468
|
let newValue = void 0;
|
|
469
469
|
listen$(ctx, key, (v) => {
|
|
470
470
|
if (useMicrotask && newValue === void 0) {
|
|
@@ -504,7 +504,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
504
504
|
const containers = [];
|
|
505
505
|
for (let i = 0; i < numContainers; i++) {
|
|
506
506
|
containers.push(
|
|
507
|
-
/* @__PURE__ */
|
|
507
|
+
/* @__PURE__ */ React3__namespace.createElement(
|
|
508
508
|
Container,
|
|
509
509
|
{
|
|
510
510
|
id: i,
|
|
@@ -533,16 +533,41 @@ var Containers = typedMemo(function Containers2({
|
|
|
533
533
|
}
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
|
-
return /* @__PURE__ */
|
|
536
|
+
return /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { style }, containers);
|
|
537
537
|
});
|
|
538
|
+
function ListHeaderComponentContainer({
|
|
539
|
+
children,
|
|
540
|
+
style,
|
|
541
|
+
ctx,
|
|
542
|
+
horizontal,
|
|
543
|
+
waitForInitialLayout
|
|
544
|
+
}) {
|
|
545
|
+
const scrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
546
|
+
const animOpacity = waitForInitialLayout ? useValue$("containersDidLayout", (value) => value ? 1 : 0) : void 0;
|
|
547
|
+
const additionalSize = {
|
|
548
|
+
transform: [{ translateY: reactNative.Animated.multiply(scrollAdjust, -1) }],
|
|
549
|
+
opacity: animOpacity
|
|
550
|
+
};
|
|
551
|
+
return /* @__PURE__ */ React.createElement(
|
|
552
|
+
reactNative.Animated.View,
|
|
553
|
+
{
|
|
554
|
+
style: [style, additionalSize],
|
|
555
|
+
onLayout: (event) => {
|
|
556
|
+
const size = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
557
|
+
set$(ctx, "headerSize", size);
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
children
|
|
561
|
+
);
|
|
562
|
+
}
|
|
538
563
|
|
|
539
564
|
// src/ListComponent.tsx
|
|
540
565
|
var getComponent = (Component) => {
|
|
541
|
-
if (
|
|
566
|
+
if (React3__namespace.isValidElement(Component)) {
|
|
542
567
|
return Component;
|
|
543
568
|
}
|
|
544
569
|
if (Component) {
|
|
545
|
-
return /* @__PURE__ */
|
|
570
|
+
return /* @__PURE__ */ React3__namespace.createElement(Component, null);
|
|
546
571
|
}
|
|
547
572
|
return null;
|
|
548
573
|
};
|
|
@@ -550,12 +575,12 @@ var PaddingAndAdjust = () => {
|
|
|
550
575
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
551
576
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
552
577
|
const additionalSize = { marginTop: animScrollAdjust, paddingTop: animPaddingTop };
|
|
553
|
-
return /* @__PURE__ */
|
|
578
|
+
return /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { style: additionalSize });
|
|
554
579
|
};
|
|
555
580
|
var PaddingAndAdjustDevMode = () => {
|
|
556
581
|
const animPaddingTop = useValue$("paddingTop", (v) => v, true);
|
|
557
582
|
const animScrollAdjust = useValue$("scrollAdjust", (v) => v, true);
|
|
558
|
-
return /* @__PURE__ */
|
|
583
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { style: { marginTop: animScrollAdjust } }), /* @__PURE__ */ React3__namespace.createElement(reactNative.Animated.View, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React3__namespace.createElement(
|
|
559
584
|
reactNative.Animated.View,
|
|
560
585
|
{
|
|
561
586
|
style: {
|
|
@@ -567,7 +592,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
567
592
|
backgroundColor: "green"
|
|
568
593
|
}
|
|
569
594
|
}
|
|
570
|
-
), /* @__PURE__ */
|
|
595
|
+
), /* @__PURE__ */ React3__namespace.createElement(
|
|
571
596
|
reactNative.Animated.View,
|
|
572
597
|
{
|
|
573
598
|
style: {
|
|
@@ -579,7 +604,7 @@ var PaddingAndAdjustDevMode = () => {
|
|
|
579
604
|
backgroundColor: "lightblue"
|
|
580
605
|
}
|
|
581
606
|
}
|
|
582
|
-
), /* @__PURE__ */
|
|
607
|
+
), /* @__PURE__ */ React3__namespace.createElement(
|
|
583
608
|
reactNative.Animated.View,
|
|
584
609
|
{
|
|
585
610
|
style: {
|
|
@@ -624,11 +649,11 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
624
649
|
...rest
|
|
625
650
|
}) {
|
|
626
651
|
const ctx = useStateContext();
|
|
627
|
-
const ScrollComponent = renderScrollComponent ?
|
|
628
|
-
() =>
|
|
652
|
+
const ScrollComponent = renderScrollComponent ? React3.useMemo(
|
|
653
|
+
() => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
629
654
|
[renderScrollComponent]
|
|
630
655
|
) : reactNative.ScrollView;
|
|
631
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ React3__namespace.createElement(
|
|
632
657
|
ScrollComponent,
|
|
633
658
|
{
|
|
634
659
|
...rest,
|
|
@@ -646,20 +671,19 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
646
671
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
647
672
|
ref: refScrollView
|
|
648
673
|
},
|
|
649
|
-
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */
|
|
650
|
-
ListHeaderComponent && /* @__PURE__ */
|
|
651
|
-
|
|
674
|
+
!ListEmptyComponent && (ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingAndAdjustDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(PaddingAndAdjust, null)),
|
|
675
|
+
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
676
|
+
ListHeaderComponentContainer,
|
|
652
677
|
{
|
|
653
678
|
style: ListHeaderComponentStyle,
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}
|
|
679
|
+
ctx,
|
|
680
|
+
horizontal,
|
|
681
|
+
waitForInitialLayout
|
|
658
682
|
},
|
|
659
683
|
getComponent(ListHeaderComponent)
|
|
660
684
|
),
|
|
661
685
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
662
|
-
/* @__PURE__ */
|
|
686
|
+
/* @__PURE__ */ React3__namespace.createElement(
|
|
663
687
|
Containers,
|
|
664
688
|
{
|
|
665
689
|
horizontal,
|
|
@@ -670,7 +694,7 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
670
694
|
updateItemSize
|
|
671
695
|
}
|
|
672
696
|
),
|
|
673
|
-
ListFooterComponent && /* @__PURE__ */
|
|
697
|
+
ListFooterComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
674
698
|
reactNative.View,
|
|
675
699
|
{
|
|
676
700
|
style: ListFooterComponentStyle,
|
|
@@ -733,7 +757,7 @@ var ScrollAdjustHandler = class {
|
|
|
733
757
|
}
|
|
734
758
|
};
|
|
735
759
|
var useCombinedRef = (...refs) => {
|
|
736
|
-
const callback =
|
|
760
|
+
const callback = React3.useCallback((element) => {
|
|
737
761
|
for (const ref of refs) {
|
|
738
762
|
if (!ref) {
|
|
739
763
|
continue;
|
|
@@ -952,7 +976,7 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
952
976
|
}
|
|
953
977
|
}
|
|
954
978
|
var LegendList = typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
955
|
-
return /* @__PURE__ */
|
|
979
|
+
return /* @__PURE__ */ React3__namespace.createElement(StateProvider, null, /* @__PURE__ */ React3__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
956
980
|
});
|
|
957
981
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
958
982
|
const {
|
|
@@ -995,7 +1019,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
995
1019
|
onViewableItemsChanged,
|
|
996
1020
|
...rest
|
|
997
1021
|
} = props;
|
|
998
|
-
const callbacks =
|
|
1022
|
+
const callbacks = React3.useRef({
|
|
999
1023
|
onStartReached: rest.onStartReached,
|
|
1000
1024
|
onEndReached: rest.onEndReached
|
|
1001
1025
|
});
|
|
@@ -1012,12 +1036,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1012
1036
|
}
|
|
1013
1037
|
const ctx = useStateContext();
|
|
1014
1038
|
ctx.columnWrapperStyle = columnWrapperStyle || (contentContainerStyle ? createColumnWrapperStyle(contentContainerStyle) : void 0);
|
|
1015
|
-
const refScroller =
|
|
1039
|
+
const refScroller = React3.useRef(null);
|
|
1016
1040
|
const combinedRef = useCombinedRef(refScroller, refScrollView);
|
|
1017
1041
|
const estimatedItemSize = estimatedItemSizeProp != null ? estimatedItemSizeProp : DEFAULT_ITEM_SIZE;
|
|
1018
1042
|
const scrollBuffer = (drawDistance != null ? drawDistance : DEFAULT_DRAW_DISTANCE) || 1;
|
|
1019
1043
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (item, index) => index.toString();
|
|
1020
|
-
const refState =
|
|
1044
|
+
const refState = React3.useRef();
|
|
1021
1045
|
const getId = (index) => {
|
|
1022
1046
|
var _a;
|
|
1023
1047
|
const data = (_a = refState.current) == null ? void 0 : _a.data;
|
|
@@ -1072,11 +1096,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1072
1096
|
offset = index * estimatedItemSize;
|
|
1073
1097
|
}
|
|
1074
1098
|
const adjust = peek$(ctx, "containersDidLayout") ? ((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0 : 0;
|
|
1075
|
-
|
|
1099
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1100
|
+
return offset / numColumnsProp - adjust + topPad;
|
|
1076
1101
|
}
|
|
1077
1102
|
return 0;
|
|
1078
1103
|
};
|
|
1079
|
-
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset :
|
|
1104
|
+
const initialContentOffset = initialScrollOffset != null ? initialScrollOffset : React3.useMemo(calculateOffsetForIndex, []);
|
|
1080
1105
|
if (!refState.current) {
|
|
1081
1106
|
const initialScrollLength = reactNative.Dimensions.get("window")[horizontal ? "width" : "height"];
|
|
1082
1107
|
refState.current = {
|
|
@@ -1105,6 +1130,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1105
1130
|
scrollPrev: 0,
|
|
1106
1131
|
scrollPrevTime: 0,
|
|
1107
1132
|
scrollTime: 0,
|
|
1133
|
+
scrollPending: 0,
|
|
1108
1134
|
indexByKey: /* @__PURE__ */ new Map(),
|
|
1109
1135
|
scrollHistory: [],
|
|
1110
1136
|
scrollVelocity: 0,
|
|
@@ -1173,11 +1199,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1173
1199
|
const firstIndexOffset = calculateOffsetForIndex(index);
|
|
1174
1200
|
let firstIndexScrollPostion = firstIndexOffset - viewOffset;
|
|
1175
1201
|
const diff = Math.abs(state.scroll - firstIndexScrollPostion);
|
|
1202
|
+
const topPad = peek$(ctx, "stylePaddingTop") + peek$(ctx, "headerSize");
|
|
1176
1203
|
const needsReanchoring = maintainVisibleContentPosition && diff > 100;
|
|
1177
1204
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
1178
1205
|
if (needsReanchoring) {
|
|
1179
1206
|
const id = getId(index);
|
|
1180
|
-
state.anchorElement = { id, coordinate: firstIndexOffset };
|
|
1207
|
+
state.anchorElement = { id, coordinate: firstIndexOffset - topPad };
|
|
1181
1208
|
(_a = state.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1182
1209
|
state.positions.clear();
|
|
1183
1210
|
calcTotalSizesAndPositions({ forgetPositions: true });
|
|
@@ -1209,7 +1236,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1209
1236
|
});
|
|
1210
1237
|
}
|
|
1211
1238
|
};
|
|
1212
|
-
const addTotalSize =
|
|
1239
|
+
const addTotalSize = React3.useCallback((key, add, totalSizeBelowAnchor) => {
|
|
1213
1240
|
const state = refState.current;
|
|
1214
1241
|
const { indexByKey, anchorElement } = state;
|
|
1215
1242
|
const index = key === null ? 0 : indexByKey.get(key);
|
|
@@ -1297,6 +1324,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1297
1324
|
state.scrollHistory.length = 0;
|
|
1298
1325
|
setTimeout(() => {
|
|
1299
1326
|
state.disableScrollJumpsFrom = void 0;
|
|
1327
|
+
if (state.scrollPending !== void 0 && state.scrollPending !== state.scroll) {
|
|
1328
|
+
updateScroll(state.scrollPending);
|
|
1329
|
+
}
|
|
1300
1330
|
}, timeout);
|
|
1301
1331
|
}
|
|
1302
1332
|
};
|
|
@@ -1313,7 +1343,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1313
1343
|
}
|
|
1314
1344
|
return res;
|
|
1315
1345
|
};
|
|
1316
|
-
const fixGaps =
|
|
1346
|
+
const fixGaps = React3.useCallback(() => {
|
|
1317
1347
|
var _a;
|
|
1318
1348
|
const state = refState.current;
|
|
1319
1349
|
const { data, scrollLength, positions, startBuffered, endBuffered } = state;
|
|
@@ -1378,7 +1408,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1378
1408
|
}
|
|
1379
1409
|
}
|
|
1380
1410
|
}, []);
|
|
1381
|
-
const checkAllSizesKnown =
|
|
1411
|
+
const checkAllSizesKnown = React3.useCallback(() => {
|
|
1382
1412
|
const { startBuffered, endBuffered, sizesKnown } = refState.current;
|
|
1383
1413
|
if (endBuffered !== null) {
|
|
1384
1414
|
let areAllKnown = true;
|
|
@@ -1390,7 +1420,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1390
1420
|
}
|
|
1391
1421
|
return false;
|
|
1392
1422
|
}, []);
|
|
1393
|
-
const calculateItemsInView =
|
|
1423
|
+
const calculateItemsInView = React3.useCallback((isReset) => {
|
|
1394
1424
|
var _a;
|
|
1395
1425
|
const state = refState.current;
|
|
1396
1426
|
const {
|
|
@@ -1410,7 +1440,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1410
1440
|
const numColumns = peek$(ctx, "numColumns");
|
|
1411
1441
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1412
1442
|
let scrollState = state.scroll;
|
|
1413
|
-
const scrollExtra =
|
|
1443
|
+
const scrollExtra = 0;
|
|
1414
1444
|
const useAverageSize = !state.disableScrollJumpsFrom && speed >= 0 && peek$(ctx, "containersDidLayout");
|
|
1415
1445
|
if (!state.queuedInitialLayout && initialScrollIndex) {
|
|
1416
1446
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
@@ -1693,6 +1723,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1693
1723
|
if (state) {
|
|
1694
1724
|
state.scrollingToOffset = void 0;
|
|
1695
1725
|
state.scrollAdjustHandler.setDisableAdjust(false);
|
|
1726
|
+
state.scrollHistory.length = 0;
|
|
1696
1727
|
calculateItemsInView();
|
|
1697
1728
|
}
|
|
1698
1729
|
};
|
|
@@ -1718,6 +1749,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1718
1749
|
if (paddingTop > 0) {
|
|
1719
1750
|
state.scroll = 0;
|
|
1720
1751
|
}
|
|
1752
|
+
state.disableScrollJumpsFrom = void 0;
|
|
1721
1753
|
requestAnimationFrame(() => {
|
|
1722
1754
|
var _a;
|
|
1723
1755
|
state.maintainingScrollAtEnd = true;
|
|
@@ -1807,8 +1839,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1807
1839
|
if (state) {
|
|
1808
1840
|
state.data = dataProp;
|
|
1809
1841
|
if (!isFirst2) {
|
|
1810
|
-
|
|
1811
|
-
|
|
1842
|
+
const totalSizeBefore = state.previousTotalSize;
|
|
1843
|
+
const totalSizeAfter = state.totalSize;
|
|
1844
|
+
const scrollDiff = state.scroll - state.scrollPrev;
|
|
1845
|
+
const sizeDiff = totalSizeAfter - totalSizeBefore;
|
|
1846
|
+
if (Math.abs(scrollDiff - sizeDiff) < 10) {
|
|
1847
|
+
disableScrollJumps(1e3);
|
|
1848
|
+
}
|
|
1812
1849
|
const numContainers = peek$(ctx, "numContainers");
|
|
1813
1850
|
for (let i = 0; i < numContainers; i++) {
|
|
1814
1851
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
@@ -1987,7 +2024,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1987
2024
|
return result.sort(comparatorDefault);
|
|
1988
2025
|
};
|
|
1989
2026
|
const isFirst = !refState.current.renderItem;
|
|
1990
|
-
const memoizedLastItemKeys =
|
|
2027
|
+
const memoizedLastItemKeys = React3.useMemo(() => {
|
|
1991
2028
|
if (!dataProp.length) return [];
|
|
1992
2029
|
return Array.from(
|
|
1993
2030
|
{ length: Math.min(numColumnsProp, dataProp.length) },
|
|
@@ -2019,9 +2056,10 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2019
2056
|
refState.current.sizes.clear();
|
|
2020
2057
|
refState.current.positions.clear();
|
|
2021
2058
|
}
|
|
2059
|
+
refState.current.previousTotalSize = peek$(ctx, "totalSize");
|
|
2022
2060
|
calcTotalSizesAndPositions({ forgetPositions: false });
|
|
2023
2061
|
}
|
|
2024
|
-
|
|
2062
|
+
React3.useEffect(() => {
|
|
2025
2063
|
const didAllocateContainers = doInitialAllocateContainers();
|
|
2026
2064
|
if (!didAllocateContainers) {
|
|
2027
2065
|
checkResetContainers(
|
|
@@ -2030,12 +2068,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2030
2068
|
);
|
|
2031
2069
|
}
|
|
2032
2070
|
}, [dataProp, numColumnsProp]);
|
|
2033
|
-
|
|
2071
|
+
React3.useEffect(() => {
|
|
2034
2072
|
set$(ctx, "extraData", extraData);
|
|
2035
2073
|
}, [extraData]);
|
|
2036
2074
|
refState.current.renderItem = renderItem;
|
|
2037
|
-
|
|
2038
|
-
const getRenderedItem =
|
|
2075
|
+
React3.useEffect(initalizeStateVars, [memoizedLastItemKeys.join(","), numColumnsProp, stylePaddingTopState]);
|
|
2076
|
+
const getRenderedItem = React3.useCallback((key) => {
|
|
2039
2077
|
var _a, _b;
|
|
2040
2078
|
const state = refState.current;
|
|
2041
2079
|
if (!state) {
|
|
@@ -2081,7 +2119,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2081
2119
|
return true;
|
|
2082
2120
|
}
|
|
2083
2121
|
};
|
|
2084
|
-
|
|
2122
|
+
React3.useEffect(() => {
|
|
2085
2123
|
const state = refState.current;
|
|
2086
2124
|
const viewability = setupViewability({
|
|
2087
2125
|
viewabilityConfig,
|
|
@@ -2094,7 +2132,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2094
2132
|
useInit(() => {
|
|
2095
2133
|
doInitialAllocateContainers();
|
|
2096
2134
|
});
|
|
2097
|
-
const updateItemSize =
|
|
2135
|
+
const updateItemSize = React3.useCallback((itemKey, size, fromFixGaps) => {
|
|
2098
2136
|
const state = refState.current;
|
|
2099
2137
|
const {
|
|
2100
2138
|
sizes,
|
|
@@ -2196,7 +2234,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2196
2234
|
}
|
|
2197
2235
|
}
|
|
2198
2236
|
}, []);
|
|
2199
|
-
const onLayout =
|
|
2237
|
+
const onLayout = React3.useCallback((event) => {
|
|
2200
2238
|
const state = refState.current;
|
|
2201
2239
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
2202
2240
|
const didChange = scrollLength !== state.scrollLength;
|
|
@@ -2225,65 +2263,78 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2225
2263
|
onLayoutProp(event);
|
|
2226
2264
|
}
|
|
2227
2265
|
}, []);
|
|
2228
|
-
const handleScroll =
|
|
2229
|
-
(event
|
|
2266
|
+
const handleScroll = React3.useCallback(
|
|
2267
|
+
(event) => {
|
|
2230
2268
|
var _a, _b, _c, _d;
|
|
2231
2269
|
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) {
|
|
2232
2270
|
return;
|
|
2233
2271
|
}
|
|
2234
2272
|
const state = refState.current;
|
|
2235
2273
|
const newScroll = event.nativeEvent.contentOffset[horizontal ? "x" : "y"];
|
|
2274
|
+
state.scrollPending = newScroll;
|
|
2236
2275
|
if (state.ignoreScrollFromCalcTotal && newScroll !== 0) {
|
|
2237
2276
|
return;
|
|
2238
2277
|
}
|
|
2239
|
-
|
|
2240
|
-
|
|
2278
|
+
updateScroll(newScroll);
|
|
2279
|
+
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
2280
|
+
},
|
|
2281
|
+
[]
|
|
2282
|
+
);
|
|
2283
|
+
const updateScroll = React3.useCallback((newScroll) => {
|
|
2284
|
+
const state = refState.current;
|
|
2285
|
+
const scrollingToOffset = state.scrollingToOffset;
|
|
2286
|
+
if (scrollingToOffset !== void 0 && Math.abs(newScroll - scrollingToOffset) < 10) {
|
|
2287
|
+
finishScrollTo();
|
|
2288
|
+
}
|
|
2289
|
+
if (state.disableScrollJumpsFrom !== void 0) {
|
|
2290
|
+
const scrollMinusAdjust = newScroll - state.scrollAdjustHandler.getAppliedAdjust();
|
|
2291
|
+
if (Math.abs(scrollMinusAdjust - state.disableScrollJumpsFrom) > 200) {
|
|
2292
|
+
return;
|
|
2241
2293
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2294
|
+
state.disableScrollJumpsFrom = void 0;
|
|
2295
|
+
}
|
|
2296
|
+
state.hasScrolled = true;
|
|
2297
|
+
state.lastBatchingAction = Date.now();
|
|
2298
|
+
const currentTime = performance.now();
|
|
2299
|
+
if (scrollingToOffset === void 0 && !(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
2300
|
+
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2301
|
+
}
|
|
2302
|
+
if (state.scrollHistory.length > 5) {
|
|
2303
|
+
state.scrollHistory.shift();
|
|
2304
|
+
}
|
|
2305
|
+
if (state.scrollTimer !== void 0) {
|
|
2306
|
+
clearTimeout(state.scrollTimer);
|
|
2307
|
+
}
|
|
2308
|
+
state.scrollTimer = setTimeout(() => {
|
|
2309
|
+
state.scrollVelocity = 0;
|
|
2310
|
+
}, 500);
|
|
2311
|
+
let velocity = 0;
|
|
2312
|
+
if (state.scrollHistory.length >= 2) {
|
|
2313
|
+
const newest = state.scrollHistory[state.scrollHistory.length - 1];
|
|
2314
|
+
let oldest;
|
|
2315
|
+
for (let i = 0; i < state.scrollHistory.length - 1; i++) {
|
|
2316
|
+
const entry = state.scrollHistory[i];
|
|
2317
|
+
if (newest.time - entry.time <= 100) {
|
|
2318
|
+
oldest = entry;
|
|
2319
|
+
break;
|
|
2246
2320
|
}
|
|
2247
|
-
state.disableScrollJumpsFrom = void 0;
|
|
2248
2321
|
}
|
|
2249
|
-
|
|
2250
|
-
state.lastBatchingAction = Date.now();
|
|
2251
|
-
const currentTime = performance.now();
|
|
2252
|
-
if (!(state.scrollHistory.length === 0 && newScroll === initialContentOffset)) {
|
|
2253
|
-
state.scrollHistory.push({ scroll: newScroll, time: currentTime });
|
|
2254
|
-
}
|
|
2255
|
-
if (state.scrollHistory.length > 5) {
|
|
2256
|
-
state.scrollHistory.shift();
|
|
2257
|
-
}
|
|
2258
|
-
if (state.scrollTimer !== void 0) {
|
|
2259
|
-
clearTimeout(state.scrollTimer);
|
|
2260
|
-
}
|
|
2261
|
-
state.scrollTimer = setTimeout(() => {
|
|
2262
|
-
state.scrollVelocity = 0;
|
|
2263
|
-
}, 500);
|
|
2264
|
-
let velocity = 0;
|
|
2265
|
-
if (state.scrollHistory.length >= 2) {
|
|
2266
|
-
const newest = state.scrollHistory[state.scrollHistory.length - 1];
|
|
2267
|
-
const oldest = state.scrollHistory[0];
|
|
2322
|
+
if (oldest) {
|
|
2268
2323
|
const scrollDiff = newest.scroll - oldest.scroll;
|
|
2269
2324
|
const timeDiff = newest.time - oldest.time;
|
|
2270
2325
|
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
2271
2326
|
}
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
},
|
|
2284
|
-
[]
|
|
2285
|
-
);
|
|
2286
|
-
React2.useImperativeHandle(
|
|
2327
|
+
}
|
|
2328
|
+
state.scrollPrev = state.scroll;
|
|
2329
|
+
state.scrollPrevTime = state.scrollTime;
|
|
2330
|
+
state.scroll = newScroll;
|
|
2331
|
+
state.scrollTime = currentTime;
|
|
2332
|
+
state.scrollVelocity = velocity;
|
|
2333
|
+
calculateItemsInView();
|
|
2334
|
+
checkAtBottom();
|
|
2335
|
+
checkAtTop();
|
|
2336
|
+
}, []);
|
|
2337
|
+
React3.useImperativeHandle(
|
|
2287
2338
|
forwardedRef,
|
|
2288
2339
|
() => {
|
|
2289
2340
|
const scrollIndexIntoView = (options) => {
|
|
@@ -2344,7 +2395,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2344
2395
|
[]
|
|
2345
2396
|
);
|
|
2346
2397
|
if (reactNative.Platform.OS === "web") {
|
|
2347
|
-
|
|
2398
|
+
React3.useEffect(() => {
|
|
2348
2399
|
var _a;
|
|
2349
2400
|
if (initialContentOffset) {
|
|
2350
2401
|
(_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.setDisableAdjust(true);
|
|
@@ -2356,7 +2407,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2356
2407
|
}
|
|
2357
2408
|
}, []);
|
|
2358
2409
|
}
|
|
2359
|
-
return /* @__PURE__ */
|
|
2410
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
2360
2411
|
ListComponent,
|
|
2361
2412
|
{
|
|
2362
2413
|
...rest,
|
|
@@ -2395,7 +2446,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2395
2446
|
maintainVisibleContentPosition,
|
|
2396
2447
|
scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
|
|
2397
2448
|
waitForInitialLayout,
|
|
2398
|
-
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */
|
|
2449
|
+
refreshControl: refreshControl != null ? refreshControl : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
|
|
2399
2450
|
reactNative.RefreshControl,
|
|
2400
2451
|
{
|
|
2401
2452
|
refreshing: !!refreshing,
|
|
@@ -2406,7 +2457,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2406
2457
|
style,
|
|
2407
2458
|
contentContainerStyle
|
|
2408
2459
|
}
|
|
2409
|
-
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */
|
|
2460
|
+
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3__namespace.createElement(DebugView, { state: refState.current }));
|
|
2410
2461
|
});
|
|
2411
2462
|
|
|
2412
2463
|
exports.LegendList = LegendList;
|