Skip to content

Commit 6aed24f

Browse files
committed
Close #143 Increase rendering laziness, 0.8.4
1 parent f6cf422 commit 6aed24f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.8.4
4+
- Non-`uniform` type lists with a `window` scroll parent will no longer render
5+
an initial page unless they are visible in the viewport. (#143)
6+
37
## 0.8.3
48
- Use `setTimeout` to detect stack overflow.
59

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-list",
3-
"version": "0.8.3",
3+
"version": "0.8.4",
44
"author": "Casey Foster <[email protected]>",
55
"license": "MIT",
66
"main": "react-list.js",

react-list.es6

+4-5
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ module.exports = class ReactList extends Component {
7575

7676
constructor(props) {
7777
super(props);
78-
const {initialIndex, pageSize} = this.props;
78+
const {initialIndex} = props;
7979
const itemsPerRow = 1;
80-
const {from, size} =
81-
this.constrain(initialIndex, pageSize, itemsPerRow, this.props);
80+
const {from, size} = this.constrain(initialIndex, 0, itemsPerRow, props);
8281
this.state = {from, size, itemsPerRow};
8382
this.cache = {};
8483
this.prevPrevState = {};
@@ -392,8 +391,8 @@ module.exports = class ReactList extends Component {
392391
if (itemSizeEstimator) return itemSizeEstimator(index, cache);
393392
}
394393

395-
constrain(from, size, itemsPerRow, {length, pageSize, type}) {
396-
size = Math.max(size, pageSize);
394+
constrain(from, size, itemsPerRow, {length, type}) {
395+
if (type === 'uniform') size = Math.max(size, 1);
397396
let mod = size % itemsPerRow;
398397
if (mod) size += itemsPerRow - mod;
399398
if (size > length) size = length;

react-list.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@
124124

125125
var _this = _possibleConstructorReturn(this, (ReactList.__proto__ || Object.getPrototypeOf(ReactList)).call(this, props));
126126

127-
var _this$props = _this.props,
128-
initialIndex = _this$props.initialIndex,
129-
pageSize = _this$props.pageSize;
127+
var initialIndex = props.initialIndex;
130128

131129
var itemsPerRow = 1;
132130

133-
var _this$constrain = _this.constrain(initialIndex, pageSize, itemsPerRow, _this.props),
131+
var _this$constrain = _this.constrain(initialIndex, 0, itemsPerRow, props),
134132
from = _this$constrain.from,
135133
size = _this$constrain.size;
136134

@@ -523,10 +521,9 @@
523521
key: 'constrain',
524522
value: function constrain(from, size, itemsPerRow, _ref) {
525523
var length = _ref.length,
526-
pageSize = _ref.pageSize,
527524
type = _ref.type;
528525

529-
size = Math.max(size, pageSize);
526+
if (type === 'uniform') size = Math.max(size, 1);
530527
var mod = size % itemsPerRow;
531528
if (mod) size += itemsPerRow - mod;
532529
if (size > length) size = length;

0 commit comments

Comments
 (0)