Skip to content

Commit

Permalink
Make item padding configurable. Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
jkimbo committed Mar 1, 2015
1 parent 74b3f81 commit 5a2792b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions dist/lazy-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ var cx = React.addons.classSet;
var LazyRender = React.createClass({displayName: 'LazyRender',
propTypes: {
children: React.PropTypes.array.isRequired,
maxHeight: React.PropTypes.number.isRequired
maxHeight: React.PropTypes.number.isRequired,

itemPadding: React.PropTypes.number
},

getDefaultProps: function() {
return {
padding: 3
itemPadding: 3
};
},

Expand Down Expand Up @@ -72,7 +74,7 @@ var LazyRender = React.createClass({displayName: 'LazyRender',
var numberOfItems = Math.ceil(height / this.state.childHeight);

if (height === this.props.maxHeight) {
numberOfItems += this.props.padding;
numberOfItems += this.props.itemPadding;
}

this.setState({
Expand All @@ -96,7 +98,7 @@ var LazyRender = React.createClass({displayName: 'LazyRender',
var numberOfItems = Math.ceil(height / childHeight);

if (height === this.props.maxHeight) {
numberOfItems += this.props.padding;
numberOfItems += this.props.itemPadding;
}

this.setState({
Expand Down
10 changes: 6 additions & 4 deletions src/lazy-render.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ var cx = React.addons.classSet;
var LazyRender = React.createClass({
propTypes: {
children: React.PropTypes.array.isRequired,
maxHeight: React.PropTypes.number.isRequired
maxHeight: React.PropTypes.number.isRequired,

itemPadding: React.PropTypes.number
},

getDefaultProps: function() {
return {
padding: 3
itemPadding: 3
};
},

Expand Down Expand Up @@ -72,7 +74,7 @@ var LazyRender = React.createClass({
var numberOfItems = Math.ceil(height / this.state.childHeight);

if (height === this.props.maxHeight) {
numberOfItems += this.props.padding;
numberOfItems += this.props.itemPadding;
}

this.setState({
Expand All @@ -96,7 +98,7 @@ var LazyRender = React.createClass({
var numberOfItems = Math.ceil(height / childHeight);

if (height === this.props.maxHeight) {
numberOfItems += this.props.padding;
numberOfItems += this.props.itemPadding;
}

this.setState({
Expand Down

0 comments on commit 5a2792b

Please sign in to comment.