From 8ff0ff22d207fc3914ae5ed4f4a88f07fdceaf35 Mon Sep 17 00:00:00 2001 From: Wee Wee Date: Sun, 14 Jan 2018 13:47:20 -0800 Subject: [PATCH] feat: add more parameters to rowHeight. Fixes #199 Added `treeIndex`, `node` and `path` to the parameters. --- src/react-sortable-tree.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/react-sortable-tree.js b/src/react-sortable-tree.js index a0295c82..f1ad52bb 100644 --- a/src/react-sortable-tree.js +++ b/src/react-sortable-tree.js @@ -619,7 +619,17 @@ class ReactSortableTree extends Component { estimatedRowSize={ typeof rowHeight !== 'function' ? rowHeight : undefined } - rowHeight={rowHeight} + rowHeight={ + typeof rowHeight !== 'function' + ? rowHeight + : ({ index }) => + rowHeight({ + index, + treeIndex: index, + node: rows[index].node, + path: rows[index].path, + }) + } rowRenderer={({ index, style: rowStyle }) => this.renderRow(rows[index], { listIndex: index, @@ -645,7 +655,12 @@ class ReactSortableTree extends Component { height: typeof rowHeight !== 'function' ? rowHeight - : rowHeight({ index }), + : rowHeight({ + index, + treeIndex: index, + node: row.node, + path: row.path, + }), }, getPrevRow: () => rows[index - 1] || null, matchKeys,