Skip to content

Commit f2cef21

Browse files
committed
No longer to return zero height to filter out nodes
1 parent aee69e1 commit f2cef21

File tree

8 files changed

+32195
-59
lines changed

8 files changed

+32195
-59
lines changed

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ export default (props) => (
6666
<InfiniteTree
6767
width="100%"
6868
height={400}
69-
rowHeight={({ node, tree }) => {
70-
// Returns zero height to filter out nodes
71-
if (node.state.filtered === false) {
72-
return 0;
73-
}
74-
return 30;
75-
}}
69+
rowHeight={30}
7670
data={props.data}
7771
>
7872
{({ node, tree }) => {

dist/react-infinite-tree.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! react-infinite-tree v1.0.0-alpha.1 | (c) 2017 Cheton Wu <[email protected]> | MIT | https://github.com/cheton/react-infinite-tree */
1+
/*! react-infinite-tree v1.0.0-alpha.2 | (c) 2017 Cheton Wu <[email protected]> | MIT | https://github.com/cheton/react-infinite-tree */
22
exports["InfiniteTree"] =
33
/******/ (function(modules) { // webpackBootstrap
44
/******/ // The module cache
@@ -752,17 +752,19 @@ var _class = function (_Component) {
752752
height: height,
753753
itemCount: count,
754754
itemSize: function itemSize(index) {
755-
var height = rowHeight;
755+
var node = _this4.tree.nodes[index];
756+
if (node && node.state.filtered === false) {
757+
return 0;
758+
}
756759

757760
if (typeof rowHeight === 'function') {
758-
height = rowHeight({
761+
return rowHeight({
759762
node: _this4.tree.nodes[index],
760-
tree: _this4.tree,
761-
index: index
763+
tree: _this4.tree
762764
});
763765
}
764766

765-
return height;
767+
return rowHeight; // Number or Array
766768
},
767769
renderItem: function renderItem(_ref2) {
768770
var index = _ref2.index,
@@ -775,8 +777,7 @@ var _class = function (_Component) {
775777
if (node && node.state.filtered !== false) {
776778
row = render({
777779
node: _this4.tree.nodes[index],
778-
tree: _this4.tree,
779-
index: index
780+
tree: _this4.tree
780781
});
781782
}
782783
}

dist/react-infinite-tree.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/bundle.js

Lines changed: 32172 additions & 27 deletions
Large diffs are not rendered by default.

docs/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/Tree.jsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ class Tree extends PureComponent {
9999

100100
return renderTreeNode({ node, tree, toggleState });
101101
}}
102-
rowHeight={({ node, tree }) => {
103-
if (node.state.filtered === false) {
104-
return 0;
105-
}
106-
return 30;
107-
}}
102+
rowHeight={30}
108103
loadNodes={(parentNode, done) => {
109104
const suffix = parentNode.id.replace(/(\w)+/, '');
110105
const nodes = [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-infinite-tree",
3-
"version": "1.0.0-alpha.1",
3+
"version": "1.0.0-alpha.2",
44
"description": "The infinite-tree library for React.",
55
"main": "lib/index.js",
66
"scripts": {

src/InfiniteTree.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,19 @@ export default class extends Component {
274274
height={height}
275275
itemCount={count}
276276
itemSize={(index) => {
277-
let height = rowHeight;
277+
const node = this.tree.nodes[index];
278+
if (node && node.state.filtered === false) {
279+
return 0;
280+
}
278281

279282
if (typeof rowHeight === 'function') {
280-
height = rowHeight({
283+
return rowHeight({
281284
node: this.tree.nodes[index],
282-
tree: this.tree,
283-
index: index
285+
tree: this.tree
284286
});
285287
}
286288

287-
return height;
289+
return rowHeight; // Number or Array
288290
}}
289291
renderItem={({ index, style }) => {
290292
let row = null;
@@ -294,8 +296,7 @@ export default class extends Component {
294296
if (node && node.state.filtered !== false) {
295297
row = render({
296298
node: this.tree.nodes[index],
297-
tree: this.tree,
298-
index: index
299+
tree: this.tree
299300
});
300301
}
301302
}

0 commit comments

Comments
 (0)