@legendapp/list 1.0.0-beta.8 → 1.0.0-beta.9
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/index.js +32 -26
- package/index.mjs +32 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -595,7 +595,7 @@ var LegendList = React5.forwardRef(function LegendList2(props, forwardedRef) {
|
|
|
595
595
|
return /* @__PURE__ */ React5__namespace.createElement(StateProvider, null, /* @__PURE__ */ React5__namespace.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
596
596
|
});
|
|
597
597
|
var LegendListInner = React5.forwardRef(function LegendListInner2(props, forwardedRef) {
|
|
598
|
-
var _a, _b, _c, _d, _e;
|
|
598
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
599
599
|
const {
|
|
600
600
|
data,
|
|
601
601
|
initialScrollIndex,
|
|
@@ -1219,35 +1219,37 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1219
1219
|
}
|
|
1220
1220
|
refState.current.indexByKey = indexByKey;
|
|
1221
1221
|
refState.current.positions = newPositions;
|
|
1222
|
-
if (
|
|
1223
|
-
if (
|
|
1224
|
-
if (
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1222
|
+
if (!isFirst) {
|
|
1223
|
+
if (maintainVisibleContentPosition) {
|
|
1224
|
+
if (refState.current.anchorElement == null || indexByKey.get(refState.current.anchorElement.id) == null) {
|
|
1225
|
+
if (data.length) {
|
|
1226
|
+
const newAnchorElement = {
|
|
1227
|
+
coordinate: 0,
|
|
1228
|
+
id: getId(0)
|
|
1229
|
+
};
|
|
1230
|
+
refState.current.anchorElement = newAnchorElement;
|
|
1231
|
+
(_a = refState.current.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1232
|
+
(_b = refScroller.current) == null ? void 0 : _b.scrollTo({ x: 0, y: 0, animated: false });
|
|
1233
|
+
setTimeout(() => {
|
|
1234
|
+
calculateItemsInView(0);
|
|
1235
|
+
}, 0);
|
|
1236
|
+
} else {
|
|
1237
|
+
refState.current.startBufferedId = void 0;
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
} else {
|
|
1241
|
+
if (refState.current.startBufferedId != null && newPositions.get(refState.current.startBufferedId) == null) {
|
|
1242
|
+
if (data.length) {
|
|
1243
|
+
refState.current.startBufferedId = getId(0);
|
|
1244
|
+
} else {
|
|
1245
|
+
refState.current.startBufferedId = void 0;
|
|
1246
|
+
}
|
|
1247
|
+
(_c = refScroller.current) == null ? void 0 : _c.scrollTo({ x: 0, y: 0, animated: false });
|
|
1232
1248
|
setTimeout(() => {
|
|
1233
1249
|
calculateItemsInView(0);
|
|
1234
1250
|
}, 0);
|
|
1235
|
-
} else {
|
|
1236
|
-
refState.current.startBufferedId = void 0;
|
|
1237
1251
|
}
|
|
1238
1252
|
}
|
|
1239
|
-
} else {
|
|
1240
|
-
if (refState.current.startBufferedId != null && newPositions.get(refState.current.startBufferedId) == null) {
|
|
1241
|
-
if (data.length) {
|
|
1242
|
-
refState.current.startBufferedId = getId(0);
|
|
1243
|
-
} else {
|
|
1244
|
-
refState.current.startBufferedId = void 0;
|
|
1245
|
-
}
|
|
1246
|
-
refScroller.current.scrollTo({ x: 0, y: 0, animated: false });
|
|
1247
|
-
setTimeout(() => {
|
|
1248
|
-
calculateItemsInView(0);
|
|
1249
|
-
}, 0);
|
|
1250
|
-
}
|
|
1251
1253
|
}
|
|
1252
1254
|
const anchorElementIndex = getAnchorElementIndex();
|
|
1253
1255
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -1280,7 +1282,7 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1280
1282
|
}, [extraData]);
|
|
1281
1283
|
refState.current.renderItem = renderItem;
|
|
1282
1284
|
const lastItemKey = data.length > 0 ? getId(data.length - 1) : void 0;
|
|
1283
|
-
const stylePaddingTop = (
|
|
1285
|
+
const stylePaddingTop = (_g = (_f = (_d = reactNative.StyleSheet.flatten(style)) == null ? void 0 : _d.paddingTop) != null ? _f : (_e = reactNative.StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _e.paddingTop) != null ? _g : 0;
|
|
1284
1286
|
const initalizeStateVars = () => {
|
|
1285
1287
|
set$(ctx, "lastItemKey", lastItemKey);
|
|
1286
1288
|
set$(ctx, "numColumns", numColumnsProp);
|
|
@@ -1415,11 +1417,15 @@ var LegendListInner = React5.forwardRef(function LegendListInner2(props, forward
|
|
|
1415
1417
|
}, []);
|
|
1416
1418
|
const onLayout = React5.useCallback((event) => {
|
|
1417
1419
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
1420
|
+
const didChange = scrollLength !== refState.current.scrollLength;
|
|
1418
1421
|
refState.current.scrollLength = scrollLength;
|
|
1419
1422
|
doMaintainScrollAtEnd(false);
|
|
1420
1423
|
doUpdatePaddingTop();
|
|
1421
1424
|
checkAtBottom();
|
|
1422
1425
|
checkAtTop();
|
|
1426
|
+
if (didChange) {
|
|
1427
|
+
calculateItemsInView(0);
|
|
1428
|
+
}
|
|
1423
1429
|
if (__DEV__) {
|
|
1424
1430
|
const isWidthZero = event.nativeEvent.layout.width === 0;
|
|
1425
1431
|
const isHeightZero = event.nativeEvent.layout.height === 0;
|
package/index.mjs
CHANGED
|
@@ -574,7 +574,7 @@ var LegendList = forwardRef(function LegendList2(props, forwardedRef) {
|
|
|
574
574
|
return /* @__PURE__ */ React5.createElement(StateProvider, null, /* @__PURE__ */ React5.createElement(LegendListInner, { ...props, ref: forwardedRef }));
|
|
575
575
|
});
|
|
576
576
|
var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef) {
|
|
577
|
-
var _a, _b, _c, _d, _e;
|
|
577
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
578
578
|
const {
|
|
579
579
|
data,
|
|
580
580
|
initialScrollIndex,
|
|
@@ -1198,35 +1198,37 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1198
1198
|
}
|
|
1199
1199
|
refState.current.indexByKey = indexByKey;
|
|
1200
1200
|
refState.current.positions = newPositions;
|
|
1201
|
-
if (
|
|
1202
|
-
if (
|
|
1203
|
-
if (
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1201
|
+
if (!isFirst) {
|
|
1202
|
+
if (maintainVisibleContentPosition) {
|
|
1203
|
+
if (refState.current.anchorElement == null || indexByKey.get(refState.current.anchorElement.id) == null) {
|
|
1204
|
+
if (data.length) {
|
|
1205
|
+
const newAnchorElement = {
|
|
1206
|
+
coordinate: 0,
|
|
1207
|
+
id: getId(0)
|
|
1208
|
+
};
|
|
1209
|
+
refState.current.anchorElement = newAnchorElement;
|
|
1210
|
+
(_a = refState.current.belowAnchorElementPositions) == null ? void 0 : _a.clear();
|
|
1211
|
+
(_b = refScroller.current) == null ? void 0 : _b.scrollTo({ x: 0, y: 0, animated: false });
|
|
1212
|
+
setTimeout(() => {
|
|
1213
|
+
calculateItemsInView(0);
|
|
1214
|
+
}, 0);
|
|
1215
|
+
} else {
|
|
1216
|
+
refState.current.startBufferedId = void 0;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
} else {
|
|
1220
|
+
if (refState.current.startBufferedId != null && newPositions.get(refState.current.startBufferedId) == null) {
|
|
1221
|
+
if (data.length) {
|
|
1222
|
+
refState.current.startBufferedId = getId(0);
|
|
1223
|
+
} else {
|
|
1224
|
+
refState.current.startBufferedId = void 0;
|
|
1225
|
+
}
|
|
1226
|
+
(_c = refScroller.current) == null ? void 0 : _c.scrollTo({ x: 0, y: 0, animated: false });
|
|
1211
1227
|
setTimeout(() => {
|
|
1212
1228
|
calculateItemsInView(0);
|
|
1213
1229
|
}, 0);
|
|
1214
|
-
} else {
|
|
1215
|
-
refState.current.startBufferedId = void 0;
|
|
1216
1230
|
}
|
|
1217
1231
|
}
|
|
1218
|
-
} else {
|
|
1219
|
-
if (refState.current.startBufferedId != null && newPositions.get(refState.current.startBufferedId) == null) {
|
|
1220
|
-
if (data.length) {
|
|
1221
|
-
refState.current.startBufferedId = getId(0);
|
|
1222
|
-
} else {
|
|
1223
|
-
refState.current.startBufferedId = void 0;
|
|
1224
|
-
}
|
|
1225
|
-
refScroller.current.scrollTo({ x: 0, y: 0, animated: false });
|
|
1226
|
-
setTimeout(() => {
|
|
1227
|
-
calculateItemsInView(0);
|
|
1228
|
-
}, 0);
|
|
1229
|
-
}
|
|
1230
1232
|
}
|
|
1231
1233
|
const anchorElementIndex = getAnchorElementIndex();
|
|
1232
1234
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -1259,7 +1261,7 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1259
1261
|
}, [extraData]);
|
|
1260
1262
|
refState.current.renderItem = renderItem;
|
|
1261
1263
|
const lastItemKey = data.length > 0 ? getId(data.length - 1) : void 0;
|
|
1262
|
-
const stylePaddingTop = (
|
|
1264
|
+
const stylePaddingTop = (_g = (_f = (_d = StyleSheet.flatten(style)) == null ? void 0 : _d.paddingTop) != null ? _f : (_e = StyleSheet.flatten(contentContainerStyle)) == null ? void 0 : _e.paddingTop) != null ? _g : 0;
|
|
1263
1265
|
const initalizeStateVars = () => {
|
|
1264
1266
|
set$(ctx, "lastItemKey", lastItemKey);
|
|
1265
1267
|
set$(ctx, "numColumns", numColumnsProp);
|
|
@@ -1394,11 +1396,15 @@ var LegendListInner = forwardRef(function LegendListInner2(props, forwardedRef)
|
|
|
1394
1396
|
}, []);
|
|
1395
1397
|
const onLayout = useCallback((event) => {
|
|
1396
1398
|
const scrollLength = event.nativeEvent.layout[horizontal ? "width" : "height"];
|
|
1399
|
+
const didChange = scrollLength !== refState.current.scrollLength;
|
|
1397
1400
|
refState.current.scrollLength = scrollLength;
|
|
1398
1401
|
doMaintainScrollAtEnd(false);
|
|
1399
1402
|
doUpdatePaddingTop();
|
|
1400
1403
|
checkAtBottom();
|
|
1401
1404
|
checkAtTop();
|
|
1405
|
+
if (didChange) {
|
|
1406
|
+
calculateItemsInView(0);
|
|
1407
|
+
}
|
|
1402
1408
|
if (__DEV__) {
|
|
1403
1409
|
const isWidthZero = event.nativeEvent.layout.width === 0;
|
|
1404
1410
|
const isHeightZero = event.nativeEvent.layout.height === 0;
|