react-virtualized
Advanced tools
Comparing version 6.2.2 to 6.3.0
Changelog | ||
------------ | ||
##### 6.3.0 | ||
Added new `minimumBatchSize` property to `InfiniteLoader` to simplify HTTP request batching. | ||
Fixed edge-case NPE with `AutoSizer` when it is unmounted immediately after being mounted. | ||
##### 6.2.2 | ||
@@ -5,0 +9,0 @@ Fixed off-by-one for `InfiniteLoader` that caused it to request one too many rows when scrolled to the end of the list. |
@@ -63,3 +63,5 @@ 'use strict'; | ||
value: function componentWillUnmount() { | ||
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize); | ||
if (this._detectElementResize) { | ||
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize); | ||
} | ||
} | ||
@@ -66,0 +68,0 @@ }, { |
@@ -71,2 +71,3 @@ 'use strict'; | ||
var loadMoreRows = _props.loadMoreRows; | ||
var minimumBatchSize = _props.minimumBatchSize; | ||
var rowsCount = _props.rowsCount; | ||
@@ -81,2 +82,4 @@ var threshold = _props.threshold; | ||
isRowLoaded: isRowLoaded, | ||
minimumBatchSize: minimumBatchSize, | ||
rowsCount: rowsCount, | ||
startIndex: Math.max(0, startIndex - threshold), | ||
@@ -148,2 +151,8 @@ stopIndex: Math.min(rowsCount - 1, stopIndex + threshold) | ||
/** | ||
* Minimum number of rows to be loaded at a time. | ||
* This property can be used to batch requests to reduce HTTP requests. | ||
*/ | ||
minimumBatchSize: _react.PropTypes.number.isRequired, | ||
/** | ||
* Number of rows in list; can be arbitrary high number if actual number is unknown. | ||
@@ -161,2 +170,3 @@ */ | ||
InfiniteLoader.defaultProps = { | ||
minimumBatchSize: 10, | ||
rowsCount: 0, | ||
@@ -180,2 +190,4 @@ threshold: 15 | ||
var isRowLoaded = _ref3.isRowLoaded; | ||
var minimumBatchSize = _ref3.minimumBatchSize; | ||
var rowsCount = _ref3.rowsCount; | ||
var startIndex = _ref3.startIndex; | ||
@@ -185,2 +197,3 @@ var stopIndex = _ref3.stopIndex; | ||
var unloadedRanges = []; | ||
var rangeStartIndex = null; | ||
@@ -208,2 +221,13 @@ var rangeStopIndex = null; | ||
if (rangeStopIndex !== null) { | ||
// Attempt to satisfy :minimumBatchSize requirement but don't exceed :rowsCount | ||
var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), rowsCount - 1); | ||
for (var _i = rangeStopIndex + 1; _i <= potentialStopIndex; _i++) { | ||
if (!isRowLoaded(_i)) { | ||
rangeStopIndex = _i; | ||
} else { | ||
break; | ||
} | ||
} | ||
unloadedRanges.push({ | ||
@@ -210,0 +234,0 @@ startIndex: rangeStartIndex, |
@@ -43,3 +43,5 @@ | ||
value: function componentWillUnmount() { | ||
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize); | ||
if (this._detectElementResize) { | ||
this._detectElementResize.removeResizeListener(this._parentNode, this._onResize); | ||
} | ||
} | ||
@@ -46,0 +48,0 @@ }, { |
@@ -50,2 +50,3 @@ | ||
var loadMoreRows = _props.loadMoreRows; | ||
var minimumBatchSize = _props.minimumBatchSize; | ||
var rowsCount = _props.rowsCount; | ||
@@ -60,2 +61,4 @@ var threshold = _props.threshold; | ||
isRowLoaded: isRowLoaded, | ||
minimumBatchSize: minimumBatchSize, | ||
rowsCount: rowsCount, | ||
startIndex: Math.max(0, startIndex - threshold), | ||
@@ -126,2 +129,8 @@ stopIndex: Math.min(rowsCount - 1, stopIndex + threshold) | ||
/** | ||
* Minimum number of rows to be loaded at a time. | ||
* This property can be used to batch requests to reduce HTTP requests. | ||
*/ | ||
minimumBatchSize: PropTypes.number.isRequired, | ||
/** | ||
* Number of rows in list; can be arbitrary high number if actual number is unknown. | ||
@@ -139,2 +148,3 @@ */ | ||
InfiniteLoader.defaultProps = { | ||
minimumBatchSize: 10, | ||
rowsCount: 0, | ||
@@ -158,2 +168,4 @@ threshold: 15 | ||
var isRowLoaded = _ref3.isRowLoaded; | ||
var minimumBatchSize = _ref3.minimumBatchSize; | ||
var rowsCount = _ref3.rowsCount; | ||
var startIndex = _ref3.startIndex; | ||
@@ -163,2 +175,3 @@ var stopIndex = _ref3.stopIndex; | ||
var unloadedRanges = []; | ||
var rangeStartIndex = null; | ||
@@ -186,2 +199,13 @@ var rangeStopIndex = null; | ||
if (rangeStopIndex !== null) { | ||
// Attempt to satisfy :minimumBatchSize requirement but don't exceed :rowsCount | ||
var potentialStopIndex = Math.min(Math.max(rangeStopIndex, rangeStartIndex + minimumBatchSize - 1), rowsCount - 1); | ||
for (var _i = rangeStopIndex + 1; _i <= potentialStopIndex; _i++) { | ||
if (!isRowLoaded(_i)) { | ||
rangeStopIndex = _i; | ||
} else { | ||
break; | ||
} | ||
} | ||
unloadedRanges.push({ | ||
@@ -188,0 +212,0 @@ startIndex: rangeStartIndex, |
@@ -6,3 +6,3 @@ { | ||
"user": "bvaughn", | ||
"version": "6.2.2", | ||
"version": "6.3.0", | ||
"homepage": "https://github.com/bvaughn/react-virtualized", | ||
@@ -9,0 +9,0 @@ "main": "dist/commonjs/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
887930
10507