@legendapp/list 1.0.1 → 1.0.3
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/animated.d.mts +1 -1
- package/animated.d.ts +1 -1
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +24 -35
- package/index.mjs +24 -35
- package/keyboard-controller.d.mts +5 -5
- package/keyboard-controller.d.ts +5 -5
- package/package.json +1 -1
package/animated.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
|
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
5
|
|
|
6
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
6
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
7
7
|
alignItemsAtEnd?: boolean;
|
|
8
8
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
9
9
|
data: readonly T[];
|
package/animated.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _legendapp_list from '@legendapp/list';
|
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { Animated } from 'react-native';
|
|
5
5
|
|
|
6
|
-
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
6
|
+
declare const AnimatedLegendList: Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
7
7
|
alignItemsAtEnd?: boolean;
|
|
8
8
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
9
9
|
data: readonly T[];
|
package/index.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ declare class ScrollAdjustHandler {
|
|
|
20
20
|
unPauseAdjust(): boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
23
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
24
24
|
/**
|
|
25
25
|
* If true, aligns items at the end of the list.
|
|
26
26
|
* @default false
|
|
@@ -272,11 +272,11 @@ interface InternalState {
|
|
|
272
272
|
} | undefined;
|
|
273
273
|
enableScrollForNextCalculateItemsInView: boolean;
|
|
274
274
|
minIndexSizeChanged: number | undefined;
|
|
275
|
-
numPendingInitialLayout: number;
|
|
276
275
|
queuedInitialLayout?: boolean | undefined;
|
|
277
276
|
queuedCalculateItemsInView: number | undefined;
|
|
278
277
|
lastBatchingAction: number;
|
|
279
278
|
ignoreScrollFromCalcTotal?: boolean;
|
|
279
|
+
disableAveragesForScrolls?: number;
|
|
280
280
|
scrollingToOffset?: number | undefined;
|
|
281
281
|
averageSizes: Record<string, {
|
|
282
282
|
num: number;
|
|
@@ -462,7 +462,7 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
462
462
|
};
|
|
463
463
|
declare const typedMemo: TypedMemo;
|
|
464
464
|
|
|
465
|
-
declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
465
|
+
declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
466
466
|
alignItemsAtEnd?: boolean;
|
|
467
467
|
columnWrapperStyle?: ColumnWrapperStyle;
|
|
468
468
|
data: readonly T[];
|
package/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare class ScrollAdjustHandler {
|
|
|
20
20
|
unPauseAdjust(): boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
23
|
+
type LegendListPropsBase<ItemT, TScrollView extends ComponentProps<typeof ScrollView> | ComponentProps<typeof react_native_reanimated__default.ScrollView>> = Omit<TScrollView, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
24
24
|
/**
|
|
25
25
|
* If true, aligns items at the end of the list.
|
|
26
26
|
* @default false
|
|
@@ -272,11 +272,11 @@ interface InternalState {
|
|
|
272
272
|
} | undefined;
|
|
273
273
|
enableScrollForNextCalculateItemsInView: boolean;
|
|
274
274
|
minIndexSizeChanged: number | undefined;
|
|
275
|
-
numPendingInitialLayout: number;
|
|
276
275
|
queuedInitialLayout?: boolean | undefined;
|
|
277
276
|
queuedCalculateItemsInView: number | undefined;
|
|
278
277
|
lastBatchingAction: number;
|
|
279
278
|
ignoreScrollFromCalcTotal?: boolean;
|
|
279
|
+
disableAveragesForScrolls?: number;
|
|
280
280
|
scrollingToOffset?: number | undefined;
|
|
281
281
|
averageSizes: Record<string, {
|
|
282
282
|
num: number;
|
|
@@ -462,7 +462,7 @@ type TypedMemo = <T extends React.ComponentType<any>>(Component: T, propsAreEqua
|
|
|
462
462
|
};
|
|
463
463
|
declare const typedMemo: TypedMemo;
|
|
464
464
|
|
|
465
|
-
declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
465
|
+
declare const LegendList: <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
466
466
|
alignItemsAtEnd?: boolean;
|
|
467
467
|
columnWrapperStyle?: ColumnWrapperStyle;
|
|
468
468
|
data: readonly T[];
|
package/index.js
CHANGED
|
@@ -338,6 +338,9 @@ var Container = ({
|
|
|
338
338
|
if (itemKey !== void 0) {
|
|
339
339
|
const layout = event.nativeEvent.layout;
|
|
340
340
|
const size = roundSize(layout[horizontal ? "width" : "height"]);
|
|
341
|
+
if (!IsNewArchitecture && size === 0 && layout.x === 0 && layout.y === 0) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
341
344
|
refLastSize.current = size;
|
|
342
345
|
updateItemSize(itemKey, size);
|
|
343
346
|
}
|
|
@@ -1002,7 +1005,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1002
1005
|
} else if (estimatedItemSize) {
|
|
1003
1006
|
offset = index * estimatedItemSize;
|
|
1004
1007
|
}
|
|
1005
|
-
|
|
1008
|
+
const adjust = peek$(ctx, "containersDidLayout") ? ((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0 : 0;
|
|
1009
|
+
return offset / numColumnsProp - adjust;
|
|
1006
1010
|
}
|
|
1007
1011
|
return 0;
|
|
1008
1012
|
};
|
|
@@ -1048,7 +1052,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1048
1052
|
scrollForNextCalculateItemsInView: void 0,
|
|
1049
1053
|
enableScrollForNextCalculateItemsInView: true,
|
|
1050
1054
|
minIndexSizeChanged: 0,
|
|
1051
|
-
numPendingInitialLayout: 0,
|
|
1052
1055
|
queuedCalculateItemsInView: 0,
|
|
1053
1056
|
lastBatchingAction: Date.now(),
|
|
1054
1057
|
averageSizes: {},
|
|
@@ -1131,6 +1134,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1131
1134
|
queueMicrotask(() => {
|
|
1132
1135
|
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
1133
1136
|
requestAnimationFrame(() => {
|
|
1137
|
+
if (!IsNewArchitecture) {
|
|
1138
|
+
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
1139
|
+
}
|
|
1134
1140
|
set$(ctx, "containersDidLayout", true);
|
|
1135
1141
|
});
|
|
1136
1142
|
});
|
|
@@ -1309,7 +1315,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1309
1315
|
positions,
|
|
1310
1316
|
columns,
|
|
1311
1317
|
scrollAdjustHandler,
|
|
1312
|
-
scrollVelocity: speed
|
|
1318
|
+
scrollVelocity: speed,
|
|
1319
|
+
disableAveragesForScrolls
|
|
1313
1320
|
} = state;
|
|
1314
1321
|
if (!data || scrollLength === 0) {
|
|
1315
1322
|
return;
|
|
@@ -1320,6 +1327,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1320
1327
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1321
1328
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
1322
1329
|
let scrollState = state.scroll;
|
|
1330
|
+
const useAverageSize = !disableAveragesForScrolls;
|
|
1323
1331
|
if (!state.queuedInitialLayout && initialScrollIndex) {
|
|
1324
1332
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
1325
1333
|
scrollState = updatedOffset;
|
|
@@ -1349,6 +1357,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1349
1357
|
}
|
|
1350
1358
|
}
|
|
1351
1359
|
const scrollBottom = scroll + scrollLength;
|
|
1360
|
+
const prevEndBuffered = state.endBuffered;
|
|
1352
1361
|
let startNoBuffer = null;
|
|
1353
1362
|
let startBuffered = null;
|
|
1354
1363
|
let startBufferedId = null;
|
|
@@ -1371,13 +1380,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1371
1380
|
}
|
|
1372
1381
|
const top2 = newPosition || positions.get(id);
|
|
1373
1382
|
if (top2 !== void 0) {
|
|
1374
|
-
const size = getItemSize(
|
|
1375
|
-
id,
|
|
1376
|
-
i,
|
|
1377
|
-
data[i],
|
|
1378
|
-
/*useAverageSize*/
|
|
1379
|
-
true
|
|
1380
|
-
);
|
|
1383
|
+
const size = getItemSize(id, i, data[i], useAverageSize);
|
|
1381
1384
|
const bottom = top2 + size;
|
|
1382
1385
|
if (bottom > scroll - scrollBuffer) {
|
|
1383
1386
|
loopStart = i;
|
|
@@ -1407,13 +1410,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1407
1410
|
};
|
|
1408
1411
|
for (let i = Math.max(0, loopStart); i < data.length; i++) {
|
|
1409
1412
|
const id = getId(i);
|
|
1410
|
-
const size = getItemSize(
|
|
1411
|
-
id,
|
|
1412
|
-
i,
|
|
1413
|
-
data[i],
|
|
1414
|
-
/*useAverageSize*/
|
|
1415
|
-
true
|
|
1416
|
-
);
|
|
1413
|
+
const size = getItemSize(id, i, data[i], useAverageSize);
|
|
1417
1414
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
1418
1415
|
if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
|
|
1419
1416
|
top = getInitialTop(i);
|
|
@@ -1537,7 +1534,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1537
1534
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1538
1535
|
const pos = positions.get(id) || 0;
|
|
1539
1536
|
const size = getItemSize(id, itemIndex, data[i]);
|
|
1540
|
-
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
|
|
1537
|
+
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom || endBuffered < prevEndBuffered) {
|
|
1541
1538
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
1542
1539
|
}
|
|
1543
1540
|
} else {
|
|
@@ -1571,9 +1568,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1571
1568
|
}
|
|
1572
1569
|
}
|
|
1573
1570
|
}
|
|
1574
|
-
if (state.numPendingInitialLayout === 0) {
|
|
1575
|
-
state.numPendingInitialLayout = state.endBuffered - state.startBuffered + 1;
|
|
1576
|
-
}
|
|
1577
1571
|
if (!state.queuedInitialLayout && endBuffered !== null) {
|
|
1578
1572
|
let areAllKnown = true;
|
|
1579
1573
|
for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
|
|
@@ -1711,8 +1705,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1711
1705
|
}
|
|
1712
1706
|
const { scrollLength, scroll } = refState.current;
|
|
1713
1707
|
const distanceFromTop = scroll;
|
|
1714
|
-
|
|
1715
|
-
refState.current.isAtTop = distanceFromTopAbs < 0;
|
|
1708
|
+
refState.current.isAtTop = distanceFromTop <= 0;
|
|
1716
1709
|
refState.current.isStartReached = checkThreshold(
|
|
1717
1710
|
distanceFromTop,
|
|
1718
1711
|
false,
|
|
@@ -1733,6 +1726,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1733
1726
|
if (state) {
|
|
1734
1727
|
state.data = dataProp;
|
|
1735
1728
|
if (!isFirst2) {
|
|
1729
|
+
state.disableAveragesForScrolls = 2;
|
|
1736
1730
|
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
1737
1731
|
const numContainers = peek$(ctx, "numContainers");
|
|
1738
1732
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1958,15 +1952,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1958
1952
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, index) : index;
|
|
1959
1953
|
const prevSize = getItemSize(itemKey, index, data);
|
|
1960
1954
|
let needsCalculate = false;
|
|
1961
|
-
|
|
1962
|
-
if (state.numPendingInitialLayout > 0) {
|
|
1963
|
-
state.numPendingInitialLayout--;
|
|
1964
|
-
if (state.numPendingInitialLayout === 0) {
|
|
1965
|
-
needsCalculate = true;
|
|
1966
|
-
state.numPendingInitialLayout = -1;
|
|
1967
|
-
needsUpdateContainersDidLayout = true;
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1955
|
+
const needsUpdateContainersDidLayout = !peek$(ctx, "containersDidLayout");
|
|
1970
1956
|
sizesKnown.set(itemKey, size);
|
|
1971
1957
|
const itemType = "";
|
|
1972
1958
|
let averages = averageSizes[itemType];
|
|
@@ -1978,7 +1964,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1978
1964
|
}
|
|
1979
1965
|
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
1980
1966
|
averages.num++;
|
|
1981
|
-
if (!prevSize || Math.abs(prevSize - size) > 0.
|
|
1967
|
+
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
1982
1968
|
let diff;
|
|
1983
1969
|
needsCalculate = true;
|
|
1984
1970
|
if (numColumns > 1) {
|
|
@@ -2022,7 +2008,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2022
2008
|
if (needsUpdateContainersDidLayout || !fromFixGaps && needsCalculate && isInView) {
|
|
2023
2009
|
const scrollVelocity = state.scrollVelocity;
|
|
2024
2010
|
let didCalculate = false;
|
|
2025
|
-
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout ||
|
|
2011
|
+
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout || needsUpdateContainersDidLayout)) {
|
|
2026
2012
|
if (Date.now() - state.lastBatchingAction < 500) {
|
|
2027
2013
|
if (!state.queuedCalculateItemsInView) {
|
|
2028
2014
|
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
@@ -2035,7 +2021,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2035
2021
|
didCalculate = true;
|
|
2036
2022
|
}
|
|
2037
2023
|
}
|
|
2038
|
-
if (!didCalculate && IsNewArchitecture) {
|
|
2024
|
+
if (!didCalculate && !needsUpdateContainersDidLayout && IsNewArchitecture) {
|
|
2039
2025
|
fixGaps();
|
|
2040
2026
|
}
|
|
2041
2027
|
}
|
|
@@ -2114,6 +2100,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2114
2100
|
if (!fromSelf) {
|
|
2115
2101
|
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
2116
2102
|
}
|
|
2103
|
+
if (state.disableAveragesForScrolls) {
|
|
2104
|
+
state.disableAveragesForScrolls--;
|
|
2105
|
+
}
|
|
2117
2106
|
},
|
|
2118
2107
|
[]
|
|
2119
2108
|
);
|
package/index.mjs
CHANGED
|
@@ -317,6 +317,9 @@ var Container = ({
|
|
|
317
317
|
if (itemKey !== void 0) {
|
|
318
318
|
const layout = event.nativeEvent.layout;
|
|
319
319
|
const size = roundSize(layout[horizontal ? "width" : "height"]);
|
|
320
|
+
if (!IsNewArchitecture && size === 0 && layout.x === 0 && layout.y === 0) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
320
323
|
refLastSize.current = size;
|
|
321
324
|
updateItemSize(itemKey, size);
|
|
322
325
|
}
|
|
@@ -981,7 +984,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
981
984
|
} else if (estimatedItemSize) {
|
|
982
985
|
offset = index * estimatedItemSize;
|
|
983
986
|
}
|
|
984
|
-
|
|
987
|
+
const adjust = peek$(ctx, "containersDidLayout") ? ((_a = refState.current) == null ? void 0 : _a.scrollAdjustHandler.getAppliedAdjust()) || 0 : 0;
|
|
988
|
+
return offset / numColumnsProp - adjust;
|
|
985
989
|
}
|
|
986
990
|
return 0;
|
|
987
991
|
};
|
|
@@ -1027,7 +1031,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1027
1031
|
scrollForNextCalculateItemsInView: void 0,
|
|
1028
1032
|
enableScrollForNextCalculateItemsInView: true,
|
|
1029
1033
|
minIndexSizeChanged: 0,
|
|
1030
|
-
numPendingInitialLayout: 0,
|
|
1031
1034
|
queuedCalculateItemsInView: 0,
|
|
1032
1035
|
lastBatchingAction: Date.now(),
|
|
1033
1036
|
averageSizes: {},
|
|
@@ -1110,6 +1113,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1110
1113
|
queueMicrotask(() => {
|
|
1111
1114
|
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
1112
1115
|
requestAnimationFrame(() => {
|
|
1116
|
+
if (!IsNewArchitecture) {
|
|
1117
|
+
scrollToIndex({ index: initialScrollIndex, animated: false });
|
|
1118
|
+
}
|
|
1113
1119
|
set$(ctx, "containersDidLayout", true);
|
|
1114
1120
|
});
|
|
1115
1121
|
});
|
|
@@ -1288,7 +1294,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1288
1294
|
positions,
|
|
1289
1295
|
columns,
|
|
1290
1296
|
scrollAdjustHandler,
|
|
1291
|
-
scrollVelocity: speed
|
|
1297
|
+
scrollVelocity: speed,
|
|
1298
|
+
disableAveragesForScrolls
|
|
1292
1299
|
} = state;
|
|
1293
1300
|
if (!data || scrollLength === 0) {
|
|
1294
1301
|
return;
|
|
@@ -1299,6 +1306,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1299
1306
|
const previousScrollAdjust = scrollAdjustHandler.getAppliedAdjust();
|
|
1300
1307
|
const scrollExtra = Math.max(-16, Math.min(16, speed)) * 16;
|
|
1301
1308
|
let scrollState = state.scroll;
|
|
1309
|
+
const useAverageSize = !disableAveragesForScrolls;
|
|
1302
1310
|
if (!state.queuedInitialLayout && initialScrollIndex) {
|
|
1303
1311
|
const updatedOffset = calculateOffsetForIndex(initialScrollIndex);
|
|
1304
1312
|
scrollState = updatedOffset;
|
|
@@ -1328,6 +1336,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1328
1336
|
}
|
|
1329
1337
|
}
|
|
1330
1338
|
const scrollBottom = scroll + scrollLength;
|
|
1339
|
+
const prevEndBuffered = state.endBuffered;
|
|
1331
1340
|
let startNoBuffer = null;
|
|
1332
1341
|
let startBuffered = null;
|
|
1333
1342
|
let startBufferedId = null;
|
|
@@ -1350,13 +1359,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1350
1359
|
}
|
|
1351
1360
|
const top2 = newPosition || positions.get(id);
|
|
1352
1361
|
if (top2 !== void 0) {
|
|
1353
|
-
const size = getItemSize(
|
|
1354
|
-
id,
|
|
1355
|
-
i,
|
|
1356
|
-
data[i],
|
|
1357
|
-
/*useAverageSize*/
|
|
1358
|
-
true
|
|
1359
|
-
);
|
|
1362
|
+
const size = getItemSize(id, i, data[i], useAverageSize);
|
|
1360
1363
|
const bottom = top2 + size;
|
|
1361
1364
|
if (bottom > scroll - scrollBuffer) {
|
|
1362
1365
|
loopStart = i;
|
|
@@ -1386,13 +1389,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1386
1389
|
};
|
|
1387
1390
|
for (let i = Math.max(0, loopStart); i < data.length; i++) {
|
|
1388
1391
|
const id = getId(i);
|
|
1389
|
-
const size = getItemSize(
|
|
1390
|
-
id,
|
|
1391
|
-
i,
|
|
1392
|
-
data[i],
|
|
1393
|
-
/*useAverageSize*/
|
|
1394
|
-
true
|
|
1395
|
-
);
|
|
1392
|
+
const size = getItemSize(id, i, data[i], useAverageSize);
|
|
1396
1393
|
maxSizeInRow = Math.max(maxSizeInRow, size);
|
|
1397
1394
|
if (top === void 0 || id === ((_a = state.anchorElement) == null ? void 0 : _a.id)) {
|
|
1398
1395
|
top = getInitialTop(i);
|
|
@@ -1516,7 +1513,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1516
1513
|
const prevPos = peek$(ctx, `containerPosition${i}`);
|
|
1517
1514
|
const pos = positions.get(id) || 0;
|
|
1518
1515
|
const size = getItemSize(id, itemIndex, data[i]);
|
|
1519
|
-
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom) {
|
|
1516
|
+
if (pos + size >= scroll && pos <= scrollBottom || prevPos + size >= scroll && prevPos <= scrollBottom || endBuffered < prevEndBuffered) {
|
|
1520
1517
|
set$(ctx, `containerPosition${i}`, ANCHORED_POSITION_OUT_OF_VIEW);
|
|
1521
1518
|
}
|
|
1522
1519
|
} else {
|
|
@@ -1550,9 +1547,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1550
1547
|
}
|
|
1551
1548
|
}
|
|
1552
1549
|
}
|
|
1553
|
-
if (state.numPendingInitialLayout === 0) {
|
|
1554
|
-
state.numPendingInitialLayout = state.endBuffered - state.startBuffered + 1;
|
|
1555
|
-
}
|
|
1556
1550
|
if (!state.queuedInitialLayout && endBuffered !== null) {
|
|
1557
1551
|
let areAllKnown = true;
|
|
1558
1552
|
for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
|
|
@@ -1690,8 +1684,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1690
1684
|
}
|
|
1691
1685
|
const { scrollLength, scroll } = refState.current;
|
|
1692
1686
|
const distanceFromTop = scroll;
|
|
1693
|
-
|
|
1694
|
-
refState.current.isAtTop = distanceFromTopAbs < 0;
|
|
1687
|
+
refState.current.isAtTop = distanceFromTop <= 0;
|
|
1695
1688
|
refState.current.isStartReached = checkThreshold(
|
|
1696
1689
|
distanceFromTop,
|
|
1697
1690
|
false,
|
|
@@ -1712,6 +1705,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1712
1705
|
if (state) {
|
|
1713
1706
|
state.data = dataProp;
|
|
1714
1707
|
if (!isFirst2) {
|
|
1708
|
+
state.disableAveragesForScrolls = 2;
|
|
1715
1709
|
refState.current.scrollForNextCalculateItemsInView = void 0;
|
|
1716
1710
|
const numContainers = peek$(ctx, "numContainers");
|
|
1717
1711
|
for (let i = 0; i < numContainers; i++) {
|
|
@@ -1937,15 +1931,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1937
1931
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, index) : index;
|
|
1938
1932
|
const prevSize = getItemSize(itemKey, index, data);
|
|
1939
1933
|
let needsCalculate = false;
|
|
1940
|
-
|
|
1941
|
-
if (state.numPendingInitialLayout > 0) {
|
|
1942
|
-
state.numPendingInitialLayout--;
|
|
1943
|
-
if (state.numPendingInitialLayout === 0) {
|
|
1944
|
-
needsCalculate = true;
|
|
1945
|
-
state.numPendingInitialLayout = -1;
|
|
1946
|
-
needsUpdateContainersDidLayout = true;
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1934
|
+
const needsUpdateContainersDidLayout = !peek$(ctx, "containersDidLayout");
|
|
1949
1935
|
sizesKnown.set(itemKey, size);
|
|
1950
1936
|
const itemType = "";
|
|
1951
1937
|
let averages = averageSizes[itemType];
|
|
@@ -1957,7 +1943,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
1957
1943
|
}
|
|
1958
1944
|
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
1959
1945
|
averages.num++;
|
|
1960
|
-
if (!prevSize || Math.abs(prevSize - size) > 0.
|
|
1946
|
+
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
1961
1947
|
let diff;
|
|
1962
1948
|
needsCalculate = true;
|
|
1963
1949
|
if (numColumns > 1) {
|
|
@@ -2001,7 +1987,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2001
1987
|
if (needsUpdateContainersDidLayout || !fromFixGaps && needsCalculate && isInView) {
|
|
2002
1988
|
const scrollVelocity = state.scrollVelocity;
|
|
2003
1989
|
let didCalculate = false;
|
|
2004
|
-
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout ||
|
|
1990
|
+
if ((Number.isNaN(scrollVelocity) || Math.abs(scrollVelocity) < 1) && (!waitForInitialLayout || needsUpdateContainersDidLayout)) {
|
|
2005
1991
|
if (Date.now() - state.lastBatchingAction < 500) {
|
|
2006
1992
|
if (!state.queuedCalculateItemsInView) {
|
|
2007
1993
|
state.queuedCalculateItemsInView = requestAnimationFrame(() => {
|
|
@@ -2014,7 +2000,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2014
2000
|
didCalculate = true;
|
|
2015
2001
|
}
|
|
2016
2002
|
}
|
|
2017
|
-
if (!didCalculate && IsNewArchitecture) {
|
|
2003
|
+
if (!didCalculate && !needsUpdateContainersDidLayout && IsNewArchitecture) {
|
|
2018
2004
|
fixGaps();
|
|
2019
2005
|
}
|
|
2020
2006
|
}
|
|
@@ -2093,6 +2079,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2093
2079
|
if (!fromSelf) {
|
|
2094
2080
|
(_d = state.onScroll) == null ? void 0 : _d.call(state, event);
|
|
2095
2081
|
}
|
|
2082
|
+
if (state.disableAveragesForScrolls) {
|
|
2083
|
+
state.disableAveragesForScrolls--;
|
|
2084
|
+
}
|
|
2096
2085
|
},
|
|
2097
2086
|
[]
|
|
2098
2087
|
);
|
|
@@ -7,7 +7,7 @@ import * as react_native from 'react-native';
|
|
|
7
7
|
import { Insets } from 'react-native';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
|
|
10
|
-
declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
10
|
+
declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
11
11
|
alignItemsAtEnd?: boolean;
|
|
12
12
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
13
13
|
data: readonly T[];
|
|
@@ -58,7 +58,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
58
58
|
viewabilityConfig?: _legendapp_list.ViewabilityConfig;
|
|
59
59
|
viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
|
|
60
60
|
waitForInitialLayout?: boolean;
|
|
61
|
-
} & React.RefAttributes<LegendListRef>) => React.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
61
|
+
} & React.RefAttributes<LegendListRef>) => React.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
62
62
|
alignItemsAtEnd?: boolean;
|
|
63
63
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
64
64
|
data: readonly T[];
|
|
@@ -134,6 +134,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
134
134
|
minIndexForVisible: number;
|
|
135
135
|
} | null | undefined> | null | undefined;
|
|
136
136
|
stickyHeaderIndices?: number[] | react_native_reanimated.SharedValue<number[] | undefined> | undefined;
|
|
137
|
+
removeClippedSubviews?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
137
138
|
scrollEventThrottle?: number | react_native_reanimated.SharedValue<number | undefined> | undefined;
|
|
138
139
|
decelerationRate?: number | "fast" | "normal" | react_native_reanimated.SharedValue<number | "fast" | "normal" | undefined> | undefined;
|
|
139
140
|
horizontal?: boolean | react_native_reanimated.SharedValue<boolean | null | undefined> | null | undefined;
|
|
@@ -148,7 +149,6 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
148
149
|
onMomentumScrollBegin?: ((event: react_native.NativeSyntheticEvent<react_native.NativeScrollEvent>) => void) | react_native_reanimated.SharedValue<((event: react_native.NativeSyntheticEvent<react_native.NativeScrollEvent>) => void) | undefined> | undefined;
|
|
149
150
|
pagingEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
150
151
|
scrollEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
151
|
-
removeClippedSubviews?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
152
152
|
showsHorizontalScrollIndicator?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
153
153
|
showsVerticalScrollIndicator?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
154
154
|
stickyHeaderHiddenOnScroll?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
@@ -292,7 +292,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
292
292
|
}> | undefined;
|
|
293
293
|
} & {
|
|
294
294
|
ref?: React.Ref<LegendListRef>;
|
|
295
|
-
}) => React.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
295
|
+
}) => React.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
296
296
|
alignItemsAtEnd?: boolean;
|
|
297
297
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
298
298
|
data: readonly T[];
|
|
@@ -343,7 +343,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
343
343
|
viewabilityConfig?: _legendapp_list.ViewabilityConfig;
|
|
344
344
|
viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
|
|
345
345
|
waitForInitialLayout?: boolean;
|
|
346
|
-
} & React.RefAttributes<LegendListRef>) => React.ReactNode>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
346
|
+
} & React.RefAttributes<LegendListRef>) => React.ReactNode>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
347
347
|
alignItemsAtEnd?: boolean;
|
|
348
348
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
349
349
|
data: readonly ItemT[];
|
package/keyboard-controller.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as react_native from 'react-native';
|
|
|
7
7
|
import { Insets } from 'react-native';
|
|
8
8
|
import * as React from 'react';
|
|
9
9
|
|
|
10
|
-
declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
10
|
+
declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
11
11
|
alignItemsAtEnd?: boolean;
|
|
12
12
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
13
13
|
data: readonly T[];
|
|
@@ -58,7 +58,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
58
58
|
viewabilityConfig?: _legendapp_list.ViewabilityConfig;
|
|
59
59
|
viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
|
|
60
60
|
waitForInitialLayout?: boolean;
|
|
61
|
-
} & React.RefAttributes<LegendListRef>) => React.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
61
|
+
} & React.RefAttributes<LegendListRef>) => React.ReactNode) | react_native.Animated.AnimatedComponent<(<T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
62
62
|
alignItemsAtEnd?: boolean;
|
|
63
63
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
64
64
|
data: readonly T[];
|
|
@@ -134,6 +134,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
134
134
|
minIndexForVisible: number;
|
|
135
135
|
} | null | undefined> | null | undefined;
|
|
136
136
|
stickyHeaderIndices?: number[] | react_native_reanimated.SharedValue<number[] | undefined> | undefined;
|
|
137
|
+
removeClippedSubviews?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
137
138
|
scrollEventThrottle?: number | react_native_reanimated.SharedValue<number | undefined> | undefined;
|
|
138
139
|
decelerationRate?: number | "fast" | "normal" | react_native_reanimated.SharedValue<number | "fast" | "normal" | undefined> | undefined;
|
|
139
140
|
horizontal?: boolean | react_native_reanimated.SharedValue<boolean | null | undefined> | null | undefined;
|
|
@@ -148,7 +149,6 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
148
149
|
onMomentumScrollBegin?: ((event: react_native.NativeSyntheticEvent<react_native.NativeScrollEvent>) => void) | react_native_reanimated.SharedValue<((event: react_native.NativeSyntheticEvent<react_native.NativeScrollEvent>) => void) | undefined> | undefined;
|
|
149
150
|
pagingEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
150
151
|
scrollEnabled?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
151
|
-
removeClippedSubviews?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
152
152
|
showsHorizontalScrollIndicator?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
153
153
|
showsVerticalScrollIndicator?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
154
154
|
stickyHeaderHiddenOnScroll?: boolean | react_native_reanimated.SharedValue<boolean | undefined> | undefined;
|
|
@@ -292,7 +292,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
292
292
|
}> | undefined;
|
|
293
293
|
} & {
|
|
294
294
|
ref?: React.Ref<LegendListRef>;
|
|
295
|
-
}) => React.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
295
|
+
}) => React.ReactElement | null) = <T>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
296
296
|
alignItemsAtEnd?: boolean;
|
|
297
297
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
298
298
|
data: readonly T[];
|
|
@@ -343,7 +343,7 @@ declare const LegendList: <ItemT, ListT extends (<T>(props: Omit<Omit<react_nati
|
|
|
343
343
|
viewabilityConfig?: _legendapp_list.ViewabilityConfig;
|
|
344
344
|
viewabilityConfigCallbackPairs?: _legendapp_list.ViewabilityConfigCallbackPairs | undefined;
|
|
345
345
|
waitForInitialLayout?: boolean;
|
|
346
|
-
} & React.RefAttributes<LegendListRef>) => React.ReactNode>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices"> & {
|
|
346
|
+
} & React.RefAttributes<LegendListRef>) => React.ReactNode>(props: Omit<Omit<react_native.ScrollViewProps, "scrollEventThrottle">, "contentOffset" | "contentInset" | "maintainVisibleContentPosition" | "stickyHeaderIndices" | "removeClippedSubviews"> & {
|
|
347
347
|
alignItemsAtEnd?: boolean;
|
|
348
348
|
columnWrapperStyle?: _legendapp_list.ColumnWrapperStyle;
|
|
349
349
|
data: readonly ItemT[];
|
package/package.json
CHANGED