Basically, when scrolling, you want to decide which elements are visible, and then render to display only those elements, with one spacer element at the top and bottom to represent the elements off-screen.
Vjeux made a fiddle here that you can look at: jsfiddle .
When scrolling is performed
scrollState: function(scroll) { var visibleStart = Math.floor(scroll / this.state.recordHeight); var visibleEnd = Math.min(visibleStart + this.state.recordsPerBody, this.state.total - 1); var displayStart = Math.max(0, Math.floor(scroll / this.state.recordHeight) - this.state.recordsPerBody * 1.5); var displayEnd = Math.min(displayStart + 4 * this.state.recordsPerBody, this.state.total - 1); this.setState({ visibleStart: visibleStart, visibleEnd: visibleEnd, displayStart: displayStart, displayEnd: displayEnd, scroll: scroll }); },
and then the render function will only display lines in the range displayStart..displayEnd .
You may also be interested in ReactJS: bidirectional infinite scroll modeling .
Sophie Alpert Jan 20 '14 at 17:51 2014-01-20 17:51
source share