@legendapp/list 2.0.0-next.23 → 2.0.0-next.25

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.
Files changed (4) hide show
  1. package/index.js +80 -57
  2. package/index.mjs +80 -57
  3. package/package.json +1 -1
  4. package/.DS_Store +0 -0
package/index.js CHANGED
@@ -863,7 +863,7 @@ function calculateOffsetForIndex(ctx, state, index) {
863
863
  }
864
864
 
865
865
  // src/utils/getItemSize.ts
866
- function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize) {
866
+ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize, preferRenderedCache) {
867
867
  var _a, _b;
868
868
  const {
869
869
  sizesKnown,
@@ -884,7 +884,11 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
884
884
  sizesKnown.set(key, size);
885
885
  }
886
886
  }
887
- if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
887
+ const renderedSize = sizes.get(key);
888
+ if (size === void 0 && preferRenderedCache && renderedSize !== void 0) {
889
+ return renderedSize;
890
+ }
891
+ if (size === void 0 && useAverageSize && !scrollingTo) {
888
892
  if (itemType === "") {
889
893
  size = defaultAverageSize;
890
894
  } else {
@@ -894,11 +898,8 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
894
898
  }
895
899
  }
896
900
  }
897
- if (size === void 0) {
898
- size = sizes.get(key);
899
- if (size !== void 0) {
900
- return size;
901
- }
901
+ if (size === void 0 && renderedSize !== void 0) {
902
+ return renderedSize;
902
903
  }
903
904
  if (size === void 0) {
904
905
  size = getEstimatedItemSize ? getEstimatedItemSize(index, data, itemType) : estimatedItemSize;
@@ -931,14 +932,16 @@ var finishScrollTo = (state) => {
931
932
  // src/core/scrollTo.ts
932
933
  function scrollTo(state, params = {}) {
933
934
  var _a;
934
- const { animated } = params;
935
+ const { animated, noScrollingTo } = params;
935
936
  const {
936
937
  refScroller,
937
938
  props: { horizontal }
938
939
  } = state;
939
940
  const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
940
941
  state.scrollHistory.length = 0;
941
- state.scrollingTo = params;
942
+ if (!noScrollingTo) {
943
+ state.scrollingTo = params;
944
+ }
942
945
  state.scrollPending = offset;
943
946
  (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
944
947
  animated: !!animated,
@@ -952,10 +955,18 @@ function scrollTo(state, params = {}) {
952
955
  }
953
956
 
954
957
  // src/utils/requestAdjust.ts
955
- function requestAdjust(ctx, state, positionDiff) {
958
+ function requestAdjust(ctx, state, positionDiff, dataChanged) {
956
959
  if (Math.abs(positionDiff) > 0.1) {
960
+ const needsScrollWorkaround = reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
957
961
  const doit = () => {
958
- state.scrollAdjustHandler.requestAdjust(positionDiff);
962
+ if (needsScrollWorkaround) {
963
+ scrollTo(state, {
964
+ noScrollingTo: true,
965
+ offset: state.scroll
966
+ });
967
+ } else {
968
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
969
+ }
959
970
  };
960
971
  state.scroll += positionDiff;
961
972
  state.scrollForNextCalculateItemsInView = void 0;
@@ -974,9 +985,12 @@ function requestAdjust(ctx, state, positionDiff) {
974
985
  if (state.ignoreScrollFromMVCPTimeout) {
975
986
  clearTimeout(state.ignoreScrollFromMVCPTimeout);
976
987
  }
977
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
978
- state.ignoreScrollFromMVCP = void 0;
979
- }, 100);
988
+ state.ignoreScrollFromMVCPTimeout = setTimeout(
989
+ () => {
990
+ state.ignoreScrollFromMVCP = void 0;
991
+ },
992
+ needsScrollWorkaround ? 250 : 100
993
+ );
980
994
  } else {
981
995
  requestAnimationFrame(doit);
982
996
  }
@@ -1035,13 +1049,7 @@ function prepareMVCP(ctx, state, dataChanged) {
1035
1049
  }
1036
1050
  }
1037
1051
  if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1038
- if (reactNative.Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1039
- scrollTo(state, {
1040
- offset: state.scroll + positionDiff
1041
- });
1042
- } else {
1043
- requestAdjust(ctx, state, positionDiff);
1044
- }
1052
+ requestAdjust(ctx, state, positionDiff, dataChanged);
1045
1053
  }
1046
1054
  };
1047
1055
  }
@@ -1051,10 +1059,10 @@ function setPaddingTop(ctx, state, { stylePaddingTop, alignItemsPaddingTop }) {
1051
1059
  if (stylePaddingTop !== void 0) {
1052
1060
  const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
1053
1061
  if (stylePaddingTop < prevStylePaddingTop) {
1054
- let prevTotalSize = peek$(ctx, "totalSize");
1062
+ let prevTotalSize = peek$(ctx, "totalSize") || 0;
1055
1063
  set$(ctx, "totalSize", prevTotalSize + prevStylePaddingTop);
1056
1064
  state.timeoutSetPaddingTop = setTimeout(() => {
1057
- prevTotalSize = peek$(ctx, "totalSize");
1065
+ prevTotalSize = peek$(ctx, "totalSize") || 0;
1058
1066
  set$(ctx, "totalSize", prevTotalSize - prevStylePaddingTop);
1059
1067
  }, 16);
1060
1068
  }
@@ -1188,7 +1196,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1188
1196
  const numColumns = peek$(ctx, "numColumns");
1189
1197
  const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
1190
1198
  const scrollVelocity = getScrollVelocity(state);
1191
- const useAverageSize = false;
1199
+ const useAverageSize = !getEstimatedItemSize;
1192
1200
  const itemType = "";
1193
1201
  let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
1194
1202
  if (averageSize !== void 0) {
@@ -1204,7 +1212,16 @@ function updateAllPositions(ctx, state, dataChanged) {
1204
1212
  let bailout = false;
1205
1213
  for (let i = firstFullyOnScreenIndex - 1; i >= 0; i--) {
1206
1214
  const id = (_b = idCache.get(i)) != null ? _b : getId(state, i);
1207
- const size = (_c = sizesKnown.get(id)) != null ? _c : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1215
+ const size = (_c = sizesKnown.get(id)) != null ? _c : getItemSize(
1216
+ state,
1217
+ id,
1218
+ i,
1219
+ data[i],
1220
+ useAverageSize,
1221
+ averageSize,
1222
+ /*preferRenderedCache*/
1223
+ !!dataChanged
1224
+ );
1208
1225
  const itemColumn = columns.get(id);
1209
1226
  maxSizeInRow2 = Math.max(maxSizeInRow2, size);
1210
1227
  if (itemColumn === 1) {
@@ -1231,7 +1248,16 @@ function updateAllPositions(ctx, state, dataChanged) {
1231
1248
  const dataLength = data.length;
1232
1249
  for (let i = 0; i < dataLength; i++) {
1233
1250
  const id = (_d = idCache.get(i)) != null ? _d : getId(state, i);
1234
- const size = (_e = sizesKnown.get(id)) != null ? _e : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1251
+ const size = (_e = sizesKnown.get(id)) != null ? _e : getItemSize(
1252
+ state,
1253
+ id,
1254
+ i,
1255
+ data[i],
1256
+ useAverageSize,
1257
+ averageSize,
1258
+ /*preferRenderedCache*/
1259
+ !!dataChanged
1260
+ );
1235
1261
  if (__DEV__ && needsIndexByKey) {
1236
1262
  if (indexByKeyForChecking.has(id)) {
1237
1263
  console.error(
@@ -1472,14 +1498,14 @@ function checkAllSizesKnown(state) {
1472
1498
  // src/utils/findAvailableContainers.ts
1473
1499
  function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
1474
1500
  const numContainers = peek$(ctx, "numContainers");
1475
- const { stickyIndicesSet } = state.props;
1501
+ const { stickyContainerPool, containerItemTypes } = state;
1476
1502
  const result = [];
1477
1503
  const availableContainers = [];
1504
+ const stickyIndicesSet = state.props.stickyIndicesSet;
1478
1505
  const stickyItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => stickyIndicesSet.has(index))) || [];
1479
- const nonStickyItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => !stickyIndicesSet.has(index))) || [];
1480
1506
  const canReuseContainer = (containerIndex, requiredType) => {
1481
1507
  if (!requiredType) return true;
1482
- const existingType = state.containerItemTypes.get(containerIndex);
1508
+ const existingType = containerItemTypes.get(containerIndex);
1483
1509
  if (!existingType) return true;
1484
1510
  return existingType === requiredType;
1485
1511
  };
@@ -1488,7 +1514,7 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
1488
1514
  for (let i = 0; i < stickyItemIndices.length; i++) {
1489
1515
  const requiredType = neededTypes[typeIndex];
1490
1516
  let foundContainer = false;
1491
- for (const containerIndex of state.stickyContainerPool) {
1517
+ for (const containerIndex of stickyContainerPool) {
1492
1518
  const key = peek$(ctx, `containerItemKey${containerIndex}`);
1493
1519
  const isPendingRemoval = pendingRemoval.includes(containerIndex);
1494
1520
  if ((key === void 0 || isPendingRemoval) && canReuseContainer(containerIndex, requiredType)) {
@@ -1505,38 +1531,33 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
1505
1531
  if (!foundContainer) {
1506
1532
  const newContainerIndex = numContainers + result.filter((index) => index >= numContainers).length;
1507
1533
  result.push(newContainerIndex);
1508
- state.stickyContainerPool.add(newContainerIndex);
1534
+ stickyContainerPool.add(newContainerIndex);
1509
1535
  if (requiredItemTypes) typeIndex++;
1510
1536
  }
1511
1537
  }
1512
- if (nonStickyItemIndices.length > 0) {
1513
- for (let u = 0; u < numContainers; u++) {
1514
- if (state.stickyContainerPool.has(u)) {
1515
- continue;
1516
- }
1517
- const key = peek$(ctx, `containerItemKey${u}`);
1518
- let isOk = key === void 0;
1519
- if (!isOk) {
1520
- const index = pendingRemoval.indexOf(u);
1521
- if (index !== -1) {
1522
- pendingRemoval.splice(index, 1);
1523
- const requiredType = neededTypes[typeIndex];
1524
- isOk = canReuseContainer(u, requiredType);
1525
- }
1538
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
1539
+ if (stickyContainerPool.has(u)) {
1540
+ continue;
1541
+ }
1542
+ const key = peek$(ctx, `containerItemKey${u}`);
1543
+ let isOk = key === void 0;
1544
+ if (!isOk) {
1545
+ const index = pendingRemoval.indexOf(u);
1546
+ if (index !== -1) {
1547
+ pendingRemoval.splice(index, 1);
1548
+ const requiredType = neededTypes[typeIndex];
1549
+ isOk = canReuseContainer(u, requiredType);
1526
1550
  }
1527
- if (isOk) {
1528
- result.push(u);
1529
- if (requiredItemTypes) {
1530
- typeIndex++;
1531
- }
1532
- if (result.length >= numNeeded) {
1533
- return result;
1534
- }
1551
+ }
1552
+ if (isOk) {
1553
+ result.push(u);
1554
+ if (requiredItemTypes) {
1555
+ typeIndex++;
1535
1556
  }
1536
1557
  }
1537
1558
  }
1538
- for (let u = 0; u < numContainers; u++) {
1539
- if (state.stickyContainerPool.has(u)) {
1559
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
1560
+ if (stickyContainerPool.has(u)) {
1540
1561
  continue;
1541
1562
  }
1542
1563
  const key = peek$(ctx, `containerItemKey${u}`);
@@ -1781,7 +1802,9 @@ function calculateItemsInView(ctx, state, params = {}) {
1781
1802
  viewabilityConfigCallbackPairs,
1782
1803
  props: { getItemType, initialScroll, itemsAreEqual, keyExtractor, scrollBuffer }
1783
1804
  } = state;
1784
- const { data, stickyIndicesArr, stickyIndicesSet } = state.props;
1805
+ const { data } = state.props;
1806
+ const stickyIndicesArr = state.props.stickyIndicesArr || [];
1807
+ const stickyIndicesSet = state.props.stickyIndicesSet || /* @__PURE__ */ new Set();
1785
1808
  const prevNumContainers = peek$(ctx, "numContainers");
1786
1809
  if (!data || scrollLength === 0 || !prevNumContainers) {
1787
1810
  return;
@@ -2195,7 +2218,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
2195
2218
  // src/core/onScroll.ts
2196
2219
  function onScroll(ctx, state, event) {
2197
2220
  var _a, _b, _c, _d, _e;
2198
- if (!state.scrollProcessingEnabled) {
2221
+ if (state.scrollProcessingEnabled === false) {
2199
2222
  return;
2200
2223
  }
2201
2224
  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) {
package/index.mjs CHANGED
@@ -842,7 +842,7 @@ function calculateOffsetForIndex(ctx, state, index) {
842
842
  }
843
843
 
844
844
  // src/utils/getItemSize.ts
845
- function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize) {
845
+ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize, preferRenderedCache) {
846
846
  var _a, _b;
847
847
  const {
848
848
  sizesKnown,
@@ -863,7 +863,11 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
863
863
  sizesKnown.set(key, size);
864
864
  }
865
865
  }
866
- if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
866
+ const renderedSize = sizes.get(key);
867
+ if (size === void 0 && preferRenderedCache && renderedSize !== void 0) {
868
+ return renderedSize;
869
+ }
870
+ if (size === void 0 && useAverageSize && !scrollingTo) {
867
871
  if (itemType === "") {
868
872
  size = defaultAverageSize;
869
873
  } else {
@@ -873,11 +877,8 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
873
877
  }
874
878
  }
875
879
  }
876
- if (size === void 0) {
877
- size = sizes.get(key);
878
- if (size !== void 0) {
879
- return size;
880
- }
880
+ if (size === void 0 && renderedSize !== void 0) {
881
+ return renderedSize;
881
882
  }
882
883
  if (size === void 0) {
883
884
  size = getEstimatedItemSize ? getEstimatedItemSize(index, data, itemType) : estimatedItemSize;
@@ -910,14 +911,16 @@ var finishScrollTo = (state) => {
910
911
  // src/core/scrollTo.ts
911
912
  function scrollTo(state, params = {}) {
912
913
  var _a;
913
- const { animated } = params;
914
+ const { animated, noScrollingTo } = params;
914
915
  const {
915
916
  refScroller,
916
917
  props: { horizontal }
917
918
  } = state;
918
919
  const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
919
920
  state.scrollHistory.length = 0;
920
- state.scrollingTo = params;
921
+ if (!noScrollingTo) {
922
+ state.scrollingTo = params;
923
+ }
921
924
  state.scrollPending = offset;
922
925
  (_a = refScroller.current) == null ? void 0 : _a.scrollTo({
923
926
  animated: !!animated,
@@ -931,10 +934,18 @@ function scrollTo(state, params = {}) {
931
934
  }
932
935
 
933
936
  // src/utils/requestAdjust.ts
934
- function requestAdjust(ctx, state, positionDiff) {
937
+ function requestAdjust(ctx, state, positionDiff, dataChanged) {
935
938
  if (Math.abs(positionDiff) > 0.1) {
939
+ const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
936
940
  const doit = () => {
937
- state.scrollAdjustHandler.requestAdjust(positionDiff);
941
+ if (needsScrollWorkaround) {
942
+ scrollTo(state, {
943
+ noScrollingTo: true,
944
+ offset: state.scroll
945
+ });
946
+ } else {
947
+ state.scrollAdjustHandler.requestAdjust(positionDiff);
948
+ }
938
949
  };
939
950
  state.scroll += positionDiff;
940
951
  state.scrollForNextCalculateItemsInView = void 0;
@@ -953,9 +964,12 @@ function requestAdjust(ctx, state, positionDiff) {
953
964
  if (state.ignoreScrollFromMVCPTimeout) {
954
965
  clearTimeout(state.ignoreScrollFromMVCPTimeout);
955
966
  }
956
- state.ignoreScrollFromMVCPTimeout = setTimeout(() => {
957
- state.ignoreScrollFromMVCP = void 0;
958
- }, 100);
967
+ state.ignoreScrollFromMVCPTimeout = setTimeout(
968
+ () => {
969
+ state.ignoreScrollFromMVCP = void 0;
970
+ },
971
+ needsScrollWorkaround ? 250 : 100
972
+ );
959
973
  } else {
960
974
  requestAnimationFrame(doit);
961
975
  }
@@ -1014,13 +1028,7 @@ function prepareMVCP(ctx, state, dataChanged) {
1014
1028
  }
1015
1029
  }
1016
1030
  if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
1017
- if (Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff) {
1018
- scrollTo(state, {
1019
- offset: state.scroll + positionDiff
1020
- });
1021
- } else {
1022
- requestAdjust(ctx, state, positionDiff);
1023
- }
1031
+ requestAdjust(ctx, state, positionDiff, dataChanged);
1024
1032
  }
1025
1033
  };
1026
1034
  }
@@ -1030,10 +1038,10 @@ function setPaddingTop(ctx, state, { stylePaddingTop, alignItemsPaddingTop }) {
1030
1038
  if (stylePaddingTop !== void 0) {
1031
1039
  const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
1032
1040
  if (stylePaddingTop < prevStylePaddingTop) {
1033
- let prevTotalSize = peek$(ctx, "totalSize");
1041
+ let prevTotalSize = peek$(ctx, "totalSize") || 0;
1034
1042
  set$(ctx, "totalSize", prevTotalSize + prevStylePaddingTop);
1035
1043
  state.timeoutSetPaddingTop = setTimeout(() => {
1036
- prevTotalSize = peek$(ctx, "totalSize");
1044
+ prevTotalSize = peek$(ctx, "totalSize") || 0;
1037
1045
  set$(ctx, "totalSize", prevTotalSize - prevStylePaddingTop);
1038
1046
  }, 16);
1039
1047
  }
@@ -1167,7 +1175,7 @@ function updateAllPositions(ctx, state, dataChanged) {
1167
1175
  const numColumns = peek$(ctx, "numColumns");
1168
1176
  const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
1169
1177
  const scrollVelocity = getScrollVelocity(state);
1170
- const useAverageSize = false;
1178
+ const useAverageSize = !getEstimatedItemSize;
1171
1179
  const itemType = "";
1172
1180
  let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
1173
1181
  if (averageSize !== void 0) {
@@ -1183,7 +1191,16 @@ function updateAllPositions(ctx, state, dataChanged) {
1183
1191
  let bailout = false;
1184
1192
  for (let i = firstFullyOnScreenIndex - 1; i >= 0; i--) {
1185
1193
  const id = (_b = idCache.get(i)) != null ? _b : getId(state, i);
1186
- const size = (_c = sizesKnown.get(id)) != null ? _c : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1194
+ const size = (_c = sizesKnown.get(id)) != null ? _c : getItemSize(
1195
+ state,
1196
+ id,
1197
+ i,
1198
+ data[i],
1199
+ useAverageSize,
1200
+ averageSize,
1201
+ /*preferRenderedCache*/
1202
+ !!dataChanged
1203
+ );
1187
1204
  const itemColumn = columns.get(id);
1188
1205
  maxSizeInRow2 = Math.max(maxSizeInRow2, size);
1189
1206
  if (itemColumn === 1) {
@@ -1210,7 +1227,16 @@ function updateAllPositions(ctx, state, dataChanged) {
1210
1227
  const dataLength = data.length;
1211
1228
  for (let i = 0; i < dataLength; i++) {
1212
1229
  const id = (_d = idCache.get(i)) != null ? _d : getId(state, i);
1213
- const size = (_e = sizesKnown.get(id)) != null ? _e : getItemSize(state, id, i, data[i], useAverageSize, averageSize);
1230
+ const size = (_e = sizesKnown.get(id)) != null ? _e : getItemSize(
1231
+ state,
1232
+ id,
1233
+ i,
1234
+ data[i],
1235
+ useAverageSize,
1236
+ averageSize,
1237
+ /*preferRenderedCache*/
1238
+ !!dataChanged
1239
+ );
1214
1240
  if (__DEV__ && needsIndexByKey) {
1215
1241
  if (indexByKeyForChecking.has(id)) {
1216
1242
  console.error(
@@ -1451,14 +1477,14 @@ function checkAllSizesKnown(state) {
1451
1477
  // src/utils/findAvailableContainers.ts
1452
1478
  function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
1453
1479
  const numContainers = peek$(ctx, "numContainers");
1454
- const { stickyIndicesSet } = state.props;
1480
+ const { stickyContainerPool, containerItemTypes } = state;
1455
1481
  const result = [];
1456
1482
  const availableContainers = [];
1483
+ const stickyIndicesSet = state.props.stickyIndicesSet;
1457
1484
  const stickyItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => stickyIndicesSet.has(index))) || [];
1458
- const nonStickyItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => !stickyIndicesSet.has(index))) || [];
1459
1485
  const canReuseContainer = (containerIndex, requiredType) => {
1460
1486
  if (!requiredType) return true;
1461
- const existingType = state.containerItemTypes.get(containerIndex);
1487
+ const existingType = containerItemTypes.get(containerIndex);
1462
1488
  if (!existingType) return true;
1463
1489
  return existingType === requiredType;
1464
1490
  };
@@ -1467,7 +1493,7 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
1467
1493
  for (let i = 0; i < stickyItemIndices.length; i++) {
1468
1494
  const requiredType = neededTypes[typeIndex];
1469
1495
  let foundContainer = false;
1470
- for (const containerIndex of state.stickyContainerPool) {
1496
+ for (const containerIndex of stickyContainerPool) {
1471
1497
  const key = peek$(ctx, `containerItemKey${containerIndex}`);
1472
1498
  const isPendingRemoval = pendingRemoval.includes(containerIndex);
1473
1499
  if ((key === void 0 || isPendingRemoval) && canReuseContainer(containerIndex, requiredType)) {
@@ -1484,38 +1510,33 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
1484
1510
  if (!foundContainer) {
1485
1511
  const newContainerIndex = numContainers + result.filter((index) => index >= numContainers).length;
1486
1512
  result.push(newContainerIndex);
1487
- state.stickyContainerPool.add(newContainerIndex);
1513
+ stickyContainerPool.add(newContainerIndex);
1488
1514
  if (requiredItemTypes) typeIndex++;
1489
1515
  }
1490
1516
  }
1491
- if (nonStickyItemIndices.length > 0) {
1492
- for (let u = 0; u < numContainers; u++) {
1493
- if (state.stickyContainerPool.has(u)) {
1494
- continue;
1495
- }
1496
- const key = peek$(ctx, `containerItemKey${u}`);
1497
- let isOk = key === void 0;
1498
- if (!isOk) {
1499
- const index = pendingRemoval.indexOf(u);
1500
- if (index !== -1) {
1501
- pendingRemoval.splice(index, 1);
1502
- const requiredType = neededTypes[typeIndex];
1503
- isOk = canReuseContainer(u, requiredType);
1504
- }
1517
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
1518
+ if (stickyContainerPool.has(u)) {
1519
+ continue;
1520
+ }
1521
+ const key = peek$(ctx, `containerItemKey${u}`);
1522
+ let isOk = key === void 0;
1523
+ if (!isOk) {
1524
+ const index = pendingRemoval.indexOf(u);
1525
+ if (index !== -1) {
1526
+ pendingRemoval.splice(index, 1);
1527
+ const requiredType = neededTypes[typeIndex];
1528
+ isOk = canReuseContainer(u, requiredType);
1505
1529
  }
1506
- if (isOk) {
1507
- result.push(u);
1508
- if (requiredItemTypes) {
1509
- typeIndex++;
1510
- }
1511
- if (result.length >= numNeeded) {
1512
- return result;
1513
- }
1530
+ }
1531
+ if (isOk) {
1532
+ result.push(u);
1533
+ if (requiredItemTypes) {
1534
+ typeIndex++;
1514
1535
  }
1515
1536
  }
1516
1537
  }
1517
- for (let u = 0; u < numContainers; u++) {
1518
- if (state.stickyContainerPool.has(u)) {
1538
+ for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
1539
+ if (stickyContainerPool.has(u)) {
1519
1540
  continue;
1520
1541
  }
1521
1542
  const key = peek$(ctx, `containerItemKey${u}`);
@@ -1760,7 +1781,9 @@ function calculateItemsInView(ctx, state, params = {}) {
1760
1781
  viewabilityConfigCallbackPairs,
1761
1782
  props: { getItemType, initialScroll, itemsAreEqual, keyExtractor, scrollBuffer }
1762
1783
  } = state;
1763
- const { data, stickyIndicesArr, stickyIndicesSet } = state.props;
1784
+ const { data } = state.props;
1785
+ const stickyIndicesArr = state.props.stickyIndicesArr || [];
1786
+ const stickyIndicesSet = state.props.stickyIndicesSet || /* @__PURE__ */ new Set();
1764
1787
  const prevNumContainers = peek$(ctx, "numContainers");
1765
1788
  if (!data || scrollLength === 0 || !prevNumContainers) {
1766
1789
  return;
@@ -2174,7 +2197,7 @@ function handleLayout(ctx, state, layout, setCanRender) {
2174
2197
  // src/core/onScroll.ts
2175
2198
  function onScroll(ctx, state, event) {
2176
2199
  var _a, _b, _c, _d, _e;
2177
- if (!state.scrollProcessingEnabled) {
2200
+ if (state.scrollProcessingEnabled === false) {
2178
2201
  return;
2179
2202
  }
2180
2203
  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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "2.0.0-next.23",
3
+ "version": "2.0.0-next.25",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,
package/.DS_Store DELETED
Binary file