From dfcbda7af63cc5fd5be3b7f156846a6075d14472 Mon Sep 17 00:00:00 2001 From: Michael Deal Date: Wed, 4 Jul 2018 15:19:21 -0700 Subject: [PATCH] Fix clusterHeight() to use most current state information 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. --- dist/infinite-tree.js | 12 +++++++----- src/clusterize.js | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dist/infinite-tree.js b/dist/infinite-tree.js index 27c0588..bdcc11d 100644 --- a/dist/infinite-tree.js +++ b/dist/infinite-tree.js @@ -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 + }; } }; diff --git a/src/clusterize.js b/src/clusterize.js index faafb49..48fe988 100644 --- a/src/clusterize.js +++ b/src/clusterize.js @@ -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 }; }