react-window 1.8.7 → 1.8.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/README.md +4 -2
- package/dist/index-dev.umd.js +1 -1
- package/dist/index-dev.umd.js.map +1 -1
- package/dist/index-prod.umd.js +1 -1
- package/dist/index-prod.umd.js.map +1 -1
- package/dist/index.cjs.js +52 -35
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +52 -35
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -25
- package/src/FixedSizeList.js +9 -2
- package/src/VariableSizeList.js +3 -2
- package/src/createListComponent.js +23 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1251,17 +1251,34 @@ function createListComponent(_ref) {
|
|
|
1251
1251
|
align = 'auto';
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
-
var
|
|
1254
|
+
var _this$props2 = this.props,
|
|
1255
|
+
itemCount = _this$props2.itemCount,
|
|
1256
|
+
layout = _this$props2.layout;
|
|
1255
1257
|
var scrollOffset = this.state.scrollOffset;
|
|
1256
|
-
index = Math.max(0, Math.min(index, itemCount - 1));
|
|
1257
|
-
|
|
1258
|
+
index = Math.max(0, Math.min(index, itemCount - 1)); // The scrollbar size should be considered when scrolling an item into view, to ensure it's fully visible.
|
|
1259
|
+
// But we only need to account for its size when it's actually visible.
|
|
1260
|
+
// This is an edge case for lists; normally they only scroll in the dominant direction.
|
|
1261
|
+
|
|
1262
|
+
var scrollbarSize = 0;
|
|
1263
|
+
|
|
1264
|
+
if (this._outerRef) {
|
|
1265
|
+
var outerRef = this._outerRef;
|
|
1266
|
+
|
|
1267
|
+
if (layout === 'vertical') {
|
|
1268
|
+
scrollbarSize = outerRef.scrollWidth > outerRef.clientWidth ? getScrollbarSize() : 0;
|
|
1269
|
+
} else {
|
|
1270
|
+
scrollbarSize = outerRef.scrollHeight > outerRef.clientHeight ? getScrollbarSize() : 0;
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps, scrollbarSize));
|
|
1258
1275
|
};
|
|
1259
1276
|
|
|
1260
1277
|
_proto.componentDidMount = function componentDidMount() {
|
|
1261
|
-
var _this$
|
|
1262
|
-
direction = _this$
|
|
1263
|
-
initialScrollOffset = _this$
|
|
1264
|
-
layout = _this$
|
|
1278
|
+
var _this$props3 = this.props,
|
|
1279
|
+
direction = _this$props3.direction,
|
|
1280
|
+
initialScrollOffset = _this$props3.initialScrollOffset,
|
|
1281
|
+
layout = _this$props3.layout;
|
|
1265
1282
|
|
|
1266
1283
|
if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
|
|
1267
1284
|
var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
|
|
@@ -1277,9 +1294,9 @@ function createListComponent(_ref) {
|
|
|
1277
1294
|
};
|
|
1278
1295
|
|
|
1279
1296
|
_proto.componentDidUpdate = function componentDidUpdate() {
|
|
1280
|
-
var _this$
|
|
1281
|
-
direction = _this$
|
|
1282
|
-
layout = _this$
|
|
1297
|
+
var _this$props4 = this.props,
|
|
1298
|
+
direction = _this$props4.direction,
|
|
1299
|
+
layout = _this$props4.layout;
|
|
1283
1300
|
var _this$state = this.state,
|
|
1284
1301
|
scrollOffset = _this$state.scrollOffset,
|
|
1285
1302
|
scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
|
|
@@ -1325,24 +1342,24 @@ function createListComponent(_ref) {
|
|
|
1325
1342
|
};
|
|
1326
1343
|
|
|
1327
1344
|
_proto.render = function render() {
|
|
1328
|
-
var _this$
|
|
1329
|
-
children = _this$
|
|
1330
|
-
className = _this$
|
|
1331
|
-
direction = _this$
|
|
1332
|
-
height = _this$
|
|
1333
|
-
innerRef = _this$
|
|
1334
|
-
innerElementType = _this$
|
|
1335
|
-
innerTagName = _this$
|
|
1336
|
-
itemCount = _this$
|
|
1337
|
-
itemData = _this$
|
|
1338
|
-
_this$
|
|
1339
|
-
itemKey = _this$
|
|
1340
|
-
layout = _this$
|
|
1341
|
-
outerElementType = _this$
|
|
1342
|
-
outerTagName = _this$
|
|
1343
|
-
style = _this$
|
|
1344
|
-
useIsScrolling = _this$
|
|
1345
|
-
width = _this$
|
|
1345
|
+
var _this$props5 = this.props,
|
|
1346
|
+
children = _this$props5.children,
|
|
1347
|
+
className = _this$props5.className,
|
|
1348
|
+
direction = _this$props5.direction,
|
|
1349
|
+
height = _this$props5.height,
|
|
1350
|
+
innerRef = _this$props5.innerRef,
|
|
1351
|
+
innerElementType = _this$props5.innerElementType,
|
|
1352
|
+
innerTagName = _this$props5.innerTagName,
|
|
1353
|
+
itemCount = _this$props5.itemCount,
|
|
1354
|
+
itemData = _this$props5.itemData,
|
|
1355
|
+
_this$props5$itemKey = _this$props5.itemKey,
|
|
1356
|
+
itemKey = _this$props5$itemKey === void 0 ? defaultItemKey$1 : _this$props5$itemKey,
|
|
1357
|
+
layout = _this$props5.layout,
|
|
1358
|
+
outerElementType = _this$props5.outerElementType,
|
|
1359
|
+
outerTagName = _this$props5.outerTagName,
|
|
1360
|
+
style = _this$props5.style,
|
|
1361
|
+
useIsScrolling = _this$props5.useIsScrolling,
|
|
1362
|
+
width = _this$props5.width;
|
|
1346
1363
|
var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
|
|
1347
1364
|
|
|
1348
1365
|
var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
|
|
@@ -1423,9 +1440,9 @@ function createListComponent(_ref) {
|
|
|
1423
1440
|
;
|
|
1424
1441
|
|
|
1425
1442
|
_proto._getRangeToRender = function _getRangeToRender() {
|
|
1426
|
-
var _this$
|
|
1427
|
-
itemCount = _this$
|
|
1428
|
-
overscanCount = _this$
|
|
1443
|
+
var _this$props6 = this.props,
|
|
1444
|
+
itemCount = _this$props6.itemCount,
|
|
1445
|
+
overscanCount = _this$props6.overscanCount;
|
|
1429
1446
|
var _this$state3 = this.state,
|
|
1430
1447
|
isScrolling = _this$state3.isScrolling,
|
|
1431
1448
|
scrollDirection = _this$state3.scrollDirection,
|
|
@@ -1630,7 +1647,7 @@ var VariableSizeList = /*#__PURE__*/createListComponent({
|
|
|
1630
1647
|
return instanceProps.itemMetadataMap[index].size;
|
|
1631
1648
|
},
|
|
1632
1649
|
getEstimatedTotalSize: getEstimatedTotalSize,
|
|
1633
|
-
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps) {
|
|
1650
|
+
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
|
|
1634
1651
|
var direction = props.direction,
|
|
1635
1652
|
height = props.height,
|
|
1636
1653
|
layout = props.layout,
|
|
@@ -1643,7 +1660,7 @@ var VariableSizeList = /*#__PURE__*/createListComponent({
|
|
|
1643
1660
|
|
|
1644
1661
|
var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
|
|
1645
1662
|
var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
|
|
1646
|
-
var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size);
|
|
1663
|
+
var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size + scrollbarSize);
|
|
1647
1664
|
|
|
1648
1665
|
if (align === 'smart') {
|
|
1649
1666
|
if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
|
|
@@ -1931,7 +1948,7 @@ var FixedSizeList = /*#__PURE__*/createListComponent({
|
|
|
1931
1948
|
itemSize = _ref3.itemSize;
|
|
1932
1949
|
return itemSize * itemCount;
|
|
1933
1950
|
},
|
|
1934
|
-
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset) {
|
|
1951
|
+
getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset, instanceProps, scrollbarSize) {
|
|
1935
1952
|
var direction = _ref4.direction,
|
|
1936
1953
|
height = _ref4.height,
|
|
1937
1954
|
itemCount = _ref4.itemCount,
|
|
@@ -1943,7 +1960,7 @@ var FixedSizeList = /*#__PURE__*/createListComponent({
|
|
|
1943
1960
|
var size = isHorizontal ? width : height;
|
|
1944
1961
|
var lastItemOffset = Math.max(0, itemCount * itemSize - size);
|
|
1945
1962
|
var maxOffset = Math.min(lastItemOffset, index * itemSize);
|
|
1946
|
-
var minOffset = Math.max(0, index * itemSize - size + itemSize);
|
|
1963
|
+
var minOffset = Math.max(0, index * itemSize - size + itemSize + scrollbarSize);
|
|
1947
1964
|
|
|
1948
1965
|
if (align === 'smart') {
|
|
1949
1966
|
if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
|