Skip to content

Commit

Permalink
Fix clusterHeight() to use most current state information
Browse files Browse the repository at this point in the history
Currently `computeHeight` uses old `this.state` data to compute the clusterHeight. If the clusterHeight has changed, then this results in requring the coder to call `tree.update` twice.
  • Loading branch information
mudcube authored and cheton committed Jul 6, 2018
1 parent eddda39 commit 261b2db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 7 additions & 5 deletions dist/infinite-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -3295,11 +3295,13 @@ var Clusterize = function (_EventEmitter) {
itemHeight += Math.max(marginTop, marginBottom);
}

return {
blockHeight: this.state.itemHeight * this.options.rowsInBlock,
clusterHeight: this.state.blockHeight * this.options.blocksInCluster,
itemHeight: itemHeight
};
var blockHeight = itemHeight * this.options.rowsInBlock;

return {
blockHeight,
clusterHeight: blockHeight * this.options.blocksInCluster,
itemHeight
};
}
};

Expand Down
6 changes: 4 additions & 2 deletions src/clusterize.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ class Clusterize extends EventEmitter {
itemHeight += Math.max(marginTop, marginBottom);
}

const blockHeight = itemHeight * this.options.rowsInBlock

return {
blockHeight: this.state.itemHeight * this.options.rowsInBlock,
clusterHeight: this.state.blockHeight * this.options.blocksInCluster,
blockHeight,
clusterHeight: blockHeight * this.options.blocksInCluster,
itemHeight
};
}
Expand Down

0 comments on commit 261b2db

Please sign in to comment.