Skip to content

Commit

Permalink
Merge pull request #73 from developerdizzle/FixVersion2.2.3
Browse files Browse the repository at this point in the history
[fix] Rebuilds lib
  • Loading branch information
developerdizzle committed Feb 6, 2018
2 parents 42dbd7d + af76ab2 commit 28430b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion lib/VirtualList.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var VirtualList = function VirtualList(options) {

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

_this._isMounted = false;


_this.options = _extends({
container: typeof window !== 'undefined' ? window : undefined
}, options);
Expand Down Expand Up @@ -82,17 +85,25 @@ var VirtualList = function VirtualList(options) {
// get first and lastItemIndex
var state = (0, _getVisibleItemBounds2.default)(list, container, items, itemHeight, itemBuffer);

if (state === undefined) {
return;
}

if (state.firstItemIndex > state.lastItemIndex) {
return;
}

if (state !== undefined && (state.firstItemIndex !== this.state.firstItemIndex || state.lastItemIndex !== this.state.lastItemIndex)) {
if (state.firstItemIndex !== this.state.firstItemIndex || state.lastItemIndex !== this.state.lastItemIndex) {
this.setState(state);
}
}
}, {
key: 'refreshState',
value: function refreshState() {
if (!this._isMounted) {
return;
}

var _props = this.props,
itemHeight = _props.itemHeight,
items = _props.items,
Expand All @@ -101,6 +112,11 @@ var VirtualList = function VirtualList(options) {

this.setStateIfNeeded(this.domNode, this.options.container, items, itemHeight, itemBuffer);
}
}, {
key: 'componentWillMount',
value: function componentWillMount() {
this._isMounted = true;
}
}, {
key: 'componentDidMount',
value: function componentDidMount() {
Expand All @@ -117,6 +133,8 @@ var VirtualList = function VirtualList(options) {
}, {
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this._isMounted = false;

// remove events
this.options.container.removeEventListener('scroll', this.refreshState);
this.options.container.removeEventListener('resize', this.refreshState);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-virtual-list",
"version": "2.2.3",
"version": "2.2.4",
"description": "Super simple virtualized list React higher-order component",
"main": "lib/VirtualList.js",
"directories": {
Expand Down

0 comments on commit 28430b9

Please sign in to comment.