@legendapp/list 2.0.0-beta.4 → 2.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/index.js +68 -56
- package/index.mjs +68 -56
- package/package.json +1 -1
package/.DS_Store
ADDED
|
Binary file
|
package/index.js
CHANGED
|
@@ -915,7 +915,7 @@ function calculateOffsetForIndex(ctx, state, index) {
|
|
|
915
915
|
}
|
|
916
916
|
|
|
917
917
|
// src/utils/getItemSize.ts
|
|
918
|
-
function getItemSize(state, key, index, data, useAverageSize
|
|
918
|
+
function getItemSize(state, key, index, data, useAverageSize) {
|
|
919
919
|
var _a, _b;
|
|
920
920
|
const {
|
|
921
921
|
sizesKnown,
|
|
@@ -937,13 +937,9 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
|
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
|
|
944
|
-
if (averageSizeForType !== void 0) {
|
|
945
|
-
size = roundSize(averageSizeForType);
|
|
946
|
-
}
|
|
940
|
+
const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
|
|
941
|
+
if (averageSizeForType !== void 0) {
|
|
942
|
+
size = roundSize(averageSizeForType);
|
|
947
943
|
}
|
|
948
944
|
}
|
|
949
945
|
if (size === void 0) {
|
|
@@ -1194,9 +1190,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1194
1190
|
|
|
1195
1191
|
// src/core/updateAllPositions.ts
|
|
1196
1192
|
function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
|
|
1197
|
-
var _a, _b, _c, _d, _e, _f
|
|
1193
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1198
1194
|
const {
|
|
1199
|
-
averageSizes,
|
|
1200
1195
|
columns,
|
|
1201
1196
|
indexByKey,
|
|
1202
1197
|
positions,
|
|
@@ -1208,33 +1203,28 @@ function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
|
|
|
1208
1203
|
const numColumns = peek$(ctx, "numColumns");
|
|
1209
1204
|
const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
|
|
1210
1205
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1211
|
-
const itemType = "";
|
|
1212
|
-
let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
|
|
1213
|
-
if (averageSize !== void 0) {
|
|
1214
|
-
averageSize = roundSize(averageSize);
|
|
1215
|
-
}
|
|
1216
1206
|
let currentRowTop = 0;
|
|
1217
1207
|
let column = 1;
|
|
1218
1208
|
let maxSizeInRow = 0;
|
|
1219
1209
|
const hasColumns = numColumns > 1;
|
|
1220
1210
|
if (startIndex > 0) {
|
|
1221
1211
|
const prevIndex = startIndex - 1;
|
|
1222
|
-
const prevId = (
|
|
1223
|
-
const prevPosition = (
|
|
1212
|
+
const prevId = (_a = idCache.get(prevIndex)) != null ? _a : getId(state, prevIndex);
|
|
1213
|
+
const prevPosition = (_b = positions.get(prevId)) != null ? _b : 0;
|
|
1224
1214
|
if (hasColumns) {
|
|
1225
|
-
const prevColumn = (
|
|
1215
|
+
const prevColumn = (_c = columns.get(prevId)) != null ? _c : 1;
|
|
1226
1216
|
currentRowTop = prevPosition;
|
|
1227
1217
|
column = prevColumn % numColumns + 1;
|
|
1228
1218
|
} else {
|
|
1229
|
-
const prevSize = (
|
|
1219
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
|
|
1230
1220
|
currentRowTop = prevPosition + prevSize;
|
|
1231
1221
|
}
|
|
1232
1222
|
}
|
|
1233
1223
|
const needsIndexByKey = dataChanged || indexByKey.size === 0;
|
|
1234
1224
|
const dataLength = data.length;
|
|
1235
1225
|
for (let i = startIndex; i < dataLength; i++) {
|
|
1236
|
-
const id = (
|
|
1237
|
-
const size = (
|
|
1226
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1227
|
+
const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(state, id, i, data[i], useAverageSize);
|
|
1238
1228
|
if (__DEV__ && needsIndexByKey) {
|
|
1239
1229
|
if (indexByKeyForChecking.has(id)) {
|
|
1240
1230
|
console.error(
|
|
@@ -2115,10 +2105,30 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2115
2105
|
var _a;
|
|
2116
2106
|
const {
|
|
2117
2107
|
scrollLength,
|
|
2118
|
-
props: {
|
|
2108
|
+
props: {
|
|
2109
|
+
data,
|
|
2110
|
+
getEstimatedItemSize,
|
|
2111
|
+
getFixedItemSize,
|
|
2112
|
+
getItemType,
|
|
2113
|
+
scrollBuffer,
|
|
2114
|
+
numColumns,
|
|
2115
|
+
estimatedItemSize
|
|
2116
|
+
}
|
|
2119
2117
|
} = state;
|
|
2120
|
-
|
|
2121
|
-
|
|
2118
|
+
const hasContainers = peek$(ctx, "numContainers");
|
|
2119
|
+
if (scrollLength > 0 && data.length > 0 && !hasContainers) {
|
|
2120
|
+
let averageItemSize;
|
|
2121
|
+
const fn = getFixedItemSize || getEstimatedItemSize;
|
|
2122
|
+
if (fn) {
|
|
2123
|
+
let totalSize = 0;
|
|
2124
|
+
const num = Math.min(20, data.length);
|
|
2125
|
+
for (let i = 0; i < num; i++) {
|
|
2126
|
+
totalSize += fn(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "");
|
|
2127
|
+
}
|
|
2128
|
+
averageItemSize = totalSize / num;
|
|
2129
|
+
} else {
|
|
2130
|
+
averageItemSize = estimatedItemSize;
|
|
2131
|
+
}
|
|
2122
2132
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize * numColumns);
|
|
2123
2133
|
for (let i = 0; i < numContainers; i++) {
|
|
2124
2134
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
@@ -2126,13 +2136,13 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2126
2136
|
}
|
|
2127
2137
|
set$(ctx, "numContainers", numContainers);
|
|
2128
2138
|
set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
|
|
2129
|
-
if (!IsNewArchitecture) {
|
|
2139
|
+
if (!IsNewArchitecture || state.lastLayout) {
|
|
2130
2140
|
if (state.props.initialScroll) {
|
|
2131
2141
|
requestAnimationFrame(() => {
|
|
2132
|
-
calculateItemsInView(ctx, state);
|
|
2142
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
2133
2143
|
});
|
|
2134
2144
|
} else {
|
|
2135
|
-
calculateItemsInView(ctx, state);
|
|
2145
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
2136
2146
|
}
|
|
2137
2147
|
}
|
|
2138
2148
|
return true;
|
|
@@ -2204,35 +2214,37 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2204
2214
|
const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
|
|
2205
2215
|
const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
|
|
2206
2216
|
state.lastLayout = layout;
|
|
2207
|
-
const didChange = scrollLength !== state.scrollLength;
|
|
2208
2217
|
const prevOtherAxisSize = state.otherAxisSize;
|
|
2209
|
-
state.scrollLength
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2218
|
+
const didChange = scrollLength !== state.scrollLength || otherAxisSize !== prevOtherAxisSize;
|
|
2219
|
+
if (didChange) {
|
|
2220
|
+
state.scrollLength = scrollLength;
|
|
2221
|
+
state.otherAxisSize = otherAxisSize;
|
|
2222
|
+
state.lastBatchingAction = Date.now();
|
|
2223
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
2224
|
+
doInitialAllocateContainers(ctx, state);
|
|
2225
|
+
if (needsCalculate) {
|
|
2226
|
+
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2227
|
+
}
|
|
2228
|
+
if (didChange || otherAxisSize !== prevOtherAxisSize) {
|
|
2229
|
+
set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
|
|
2230
|
+
}
|
|
2231
|
+
if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
|
|
2232
|
+
doMaintainScrollAtEnd(ctx, state, false);
|
|
2233
|
+
}
|
|
2234
|
+
updateAlignItemsPaddingTop(ctx, state);
|
|
2235
|
+
checkAtBottom(ctx, state);
|
|
2236
|
+
checkAtTop(state);
|
|
2237
|
+
if (state) {
|
|
2238
|
+
state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
|
|
2239
|
+
}
|
|
2240
|
+
if (__DEV__ && scrollLength === 0) {
|
|
2241
|
+
warnDevOnce(
|
|
2242
|
+
"height0",
|
|
2243
|
+
`List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
setCanRender(true);
|
|
2234
2247
|
}
|
|
2235
|
-
setCanRender(true);
|
|
2236
2248
|
}
|
|
2237
2249
|
|
|
2238
2250
|
// src/core/onScroll.ts
|
|
@@ -2425,7 +2437,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2425
2437
|
const prevSize = getItemSize(state, itemKey, index, data);
|
|
2426
2438
|
const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
|
|
2427
2439
|
sizesKnown.set(itemKey, size);
|
|
2428
|
-
if (!getEstimatedItemSize && !getFixedItemSize) {
|
|
2440
|
+
if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
|
|
2429
2441
|
const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
|
|
2430
2442
|
let averages = averageSizes[itemType];
|
|
2431
2443
|
if (!averages) {
|
|
@@ -2830,7 +2842,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2830
2842
|
}
|
|
2831
2843
|
}, [snapToIndices]);
|
|
2832
2844
|
React3.useLayoutEffect(() => {
|
|
2833
|
-
const didAllocateContainers = doInitialAllocateContainersCallback();
|
|
2845
|
+
const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
|
|
2834
2846
|
if (!didAllocateContainers) {
|
|
2835
2847
|
checkResetContainers(
|
|
2836
2848
|
/*isFirst*/
|
package/index.mjs
CHANGED
|
@@ -894,7 +894,7 @@ function calculateOffsetForIndex(ctx, state, index) {
|
|
|
894
894
|
}
|
|
895
895
|
|
|
896
896
|
// src/utils/getItemSize.ts
|
|
897
|
-
function getItemSize(state, key, index, data, useAverageSize
|
|
897
|
+
function getItemSize(state, key, index, data, useAverageSize) {
|
|
898
898
|
var _a, _b;
|
|
899
899
|
const {
|
|
900
900
|
sizesKnown,
|
|
@@ -916,13 +916,9 @@ function getItemSize(state, key, index, data, useAverageSize, defaultAverageSize
|
|
|
916
916
|
}
|
|
917
917
|
}
|
|
918
918
|
if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
|
|
923
|
-
if (averageSizeForType !== void 0) {
|
|
924
|
-
size = roundSize(averageSizeForType);
|
|
925
|
-
}
|
|
919
|
+
const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
|
|
920
|
+
if (averageSizeForType !== void 0) {
|
|
921
|
+
size = roundSize(averageSizeForType);
|
|
926
922
|
}
|
|
927
923
|
}
|
|
928
924
|
if (size === void 0) {
|
|
@@ -1173,9 +1169,8 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
1173
1169
|
|
|
1174
1170
|
// src/core/updateAllPositions.ts
|
|
1175
1171
|
function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
|
|
1176
|
-
var _a, _b, _c, _d, _e, _f
|
|
1172
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1177
1173
|
const {
|
|
1178
|
-
averageSizes,
|
|
1179
1174
|
columns,
|
|
1180
1175
|
indexByKey,
|
|
1181
1176
|
positions,
|
|
@@ -1187,33 +1182,28 @@ function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
|
|
|
1187
1182
|
const numColumns = peek$(ctx, "numColumns");
|
|
1188
1183
|
const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
|
|
1189
1184
|
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1190
|
-
const itemType = "";
|
|
1191
|
-
let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
|
|
1192
|
-
if (averageSize !== void 0) {
|
|
1193
|
-
averageSize = roundSize(averageSize);
|
|
1194
|
-
}
|
|
1195
1185
|
let currentRowTop = 0;
|
|
1196
1186
|
let column = 1;
|
|
1197
1187
|
let maxSizeInRow = 0;
|
|
1198
1188
|
const hasColumns = numColumns > 1;
|
|
1199
1189
|
if (startIndex > 0) {
|
|
1200
1190
|
const prevIndex = startIndex - 1;
|
|
1201
|
-
const prevId = (
|
|
1202
|
-
const prevPosition = (
|
|
1191
|
+
const prevId = (_a = idCache.get(prevIndex)) != null ? _a : getId(state, prevIndex);
|
|
1192
|
+
const prevPosition = (_b = positions.get(prevId)) != null ? _b : 0;
|
|
1203
1193
|
if (hasColumns) {
|
|
1204
|
-
const prevColumn = (
|
|
1194
|
+
const prevColumn = (_c = columns.get(prevId)) != null ? _c : 1;
|
|
1205
1195
|
currentRowTop = prevPosition;
|
|
1206
1196
|
column = prevColumn % numColumns + 1;
|
|
1207
1197
|
} else {
|
|
1208
|
-
const prevSize = (
|
|
1198
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
|
|
1209
1199
|
currentRowTop = prevPosition + prevSize;
|
|
1210
1200
|
}
|
|
1211
1201
|
}
|
|
1212
1202
|
const needsIndexByKey = dataChanged || indexByKey.size === 0;
|
|
1213
1203
|
const dataLength = data.length;
|
|
1214
1204
|
for (let i = startIndex; i < dataLength; i++) {
|
|
1215
|
-
const id = (
|
|
1216
|
-
const size = (
|
|
1205
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1206
|
+
const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(state, id, i, data[i], useAverageSize);
|
|
1217
1207
|
if (__DEV__ && needsIndexByKey) {
|
|
1218
1208
|
if (indexByKeyForChecking.has(id)) {
|
|
1219
1209
|
console.error(
|
|
@@ -2094,10 +2084,30 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2094
2084
|
var _a;
|
|
2095
2085
|
const {
|
|
2096
2086
|
scrollLength,
|
|
2097
|
-
props: {
|
|
2087
|
+
props: {
|
|
2088
|
+
data,
|
|
2089
|
+
getEstimatedItemSize,
|
|
2090
|
+
getFixedItemSize,
|
|
2091
|
+
getItemType,
|
|
2092
|
+
scrollBuffer,
|
|
2093
|
+
numColumns,
|
|
2094
|
+
estimatedItemSize
|
|
2095
|
+
}
|
|
2098
2096
|
} = state;
|
|
2099
|
-
|
|
2100
|
-
|
|
2097
|
+
const hasContainers = peek$(ctx, "numContainers");
|
|
2098
|
+
if (scrollLength > 0 && data.length > 0 && !hasContainers) {
|
|
2099
|
+
let averageItemSize;
|
|
2100
|
+
const fn = getFixedItemSize || getEstimatedItemSize;
|
|
2101
|
+
if (fn) {
|
|
2102
|
+
let totalSize = 0;
|
|
2103
|
+
const num = Math.min(20, data.length);
|
|
2104
|
+
for (let i = 0; i < num; i++) {
|
|
2105
|
+
totalSize += fn(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "");
|
|
2106
|
+
}
|
|
2107
|
+
averageItemSize = totalSize / num;
|
|
2108
|
+
} else {
|
|
2109
|
+
averageItemSize = estimatedItemSize;
|
|
2110
|
+
}
|
|
2101
2111
|
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize * numColumns);
|
|
2102
2112
|
for (let i = 0; i < numContainers; i++) {
|
|
2103
2113
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
@@ -2105,13 +2115,13 @@ function doInitialAllocateContainers(ctx, state) {
|
|
|
2105
2115
|
}
|
|
2106
2116
|
set$(ctx, "numContainers", numContainers);
|
|
2107
2117
|
set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
|
|
2108
|
-
if (!IsNewArchitecture) {
|
|
2118
|
+
if (!IsNewArchitecture || state.lastLayout) {
|
|
2109
2119
|
if (state.props.initialScroll) {
|
|
2110
2120
|
requestAnimationFrame(() => {
|
|
2111
|
-
calculateItemsInView(ctx, state);
|
|
2121
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
2112
2122
|
});
|
|
2113
2123
|
} else {
|
|
2114
|
-
calculateItemsInView(ctx, state);
|
|
2124
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
2115
2125
|
}
|
|
2116
2126
|
}
|
|
2117
2127
|
return true;
|
|
@@ -2183,35 +2193,37 @@ function handleLayout(ctx, state, layout, setCanRender) {
|
|
|
2183
2193
|
const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
|
|
2184
2194
|
const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
|
|
2185
2195
|
state.lastLayout = layout;
|
|
2186
|
-
const didChange = scrollLength !== state.scrollLength;
|
|
2187
2196
|
const prevOtherAxisSize = state.otherAxisSize;
|
|
2188
|
-
state.scrollLength
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2197
|
+
const didChange = scrollLength !== state.scrollLength || otherAxisSize !== prevOtherAxisSize;
|
|
2198
|
+
if (didChange) {
|
|
2199
|
+
state.scrollLength = scrollLength;
|
|
2200
|
+
state.otherAxisSize = otherAxisSize;
|
|
2201
|
+
state.lastBatchingAction = Date.now();
|
|
2202
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
2203
|
+
doInitialAllocateContainers(ctx, state);
|
|
2204
|
+
if (needsCalculate) {
|
|
2205
|
+
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2206
|
+
}
|
|
2207
|
+
if (didChange || otherAxisSize !== prevOtherAxisSize) {
|
|
2208
|
+
set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
|
|
2209
|
+
}
|
|
2210
|
+
if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
|
|
2211
|
+
doMaintainScrollAtEnd(ctx, state, false);
|
|
2212
|
+
}
|
|
2213
|
+
updateAlignItemsPaddingTop(ctx, state);
|
|
2214
|
+
checkAtBottom(ctx, state);
|
|
2215
|
+
checkAtTop(state);
|
|
2216
|
+
if (state) {
|
|
2217
|
+
state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
|
|
2218
|
+
}
|
|
2219
|
+
if (__DEV__ && scrollLength === 0) {
|
|
2220
|
+
warnDevOnce(
|
|
2221
|
+
"height0",
|
|
2222
|
+
`List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
|
|
2223
|
+
);
|
|
2224
|
+
}
|
|
2225
|
+
setCanRender(true);
|
|
2213
2226
|
}
|
|
2214
|
-
setCanRender(true);
|
|
2215
2227
|
}
|
|
2216
2228
|
|
|
2217
2229
|
// src/core/onScroll.ts
|
|
@@ -2404,7 +2416,7 @@ function updateOneItemSize(state, itemKey, sizeObj) {
|
|
|
2404
2416
|
const prevSize = getItemSize(state, itemKey, index, data);
|
|
2405
2417
|
const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
|
|
2406
2418
|
sizesKnown.set(itemKey, size);
|
|
2407
|
-
if (!getEstimatedItemSize && !getFixedItemSize) {
|
|
2419
|
+
if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
|
|
2408
2420
|
const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
|
|
2409
2421
|
let averages = averageSizes[itemType];
|
|
2410
2422
|
if (!averages) {
|
|
@@ -2809,7 +2821,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2809
2821
|
}
|
|
2810
2822
|
}, [snapToIndices]);
|
|
2811
2823
|
useLayoutEffect(() => {
|
|
2812
|
-
const didAllocateContainers = doInitialAllocateContainersCallback();
|
|
2824
|
+
const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
|
|
2813
2825
|
if (!didAllocateContainers) {
|
|
2814
2826
|
checkResetContainers(
|
|
2815
2827
|
/*isFirst*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/list",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.5",
|
|
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,
|