Permalink
Browse files

fix infinite scroll

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information...
icewind1991 committed Mar 27, 2017
1 parent 7833d97 commit cbe874c6c068b9156ad8456edf31d112da40cbc9
Showing with 12 additions and 1 deletion.
  1. +9 −0 css/app.css
  2. +2 −0 js/App.js
  3. +1 −1 js/Providers/LogProvider.js
View
@@ -7,6 +7,10 @@
width: 100%;
}
#logreader-root > div {
height: 100%;
}
#log-section {
display: none; /** we overwrite this */
}
@@ -17,3 +21,8 @@
left: 50%;
transform: translate(-50%, -50%);
}
.scrollContainer {
height: 100%;
overflow: auto;
}
View
@@ -58,6 +58,7 @@ export class App extends Component {
}
fetchNextPage = _.throttle(async () => {
console.log(this.state.provider.hasMore);
if (this.state.provider.hasMore) {
this.setState({loading: true});
this.state.provider.limit += 25;
@@ -134,6 +135,7 @@ export class App extends Component {
content = <div className="loading log-loading"/>
} else {
content = <ReactScrolla
className={styles.scrollContainer}
percentage={85}
onPercentage={this.fetchNextPage}
isLoading={this.state.loading}>
@@ -44,7 +44,7 @@ export class LogProvider extends EventEmitter {
if (this.cachedEntries.length >= this.limit || this.fromFile || !this.hasMore) {
return;
}
var newData = await this.loadEntries(this.cachedEntries.length, this.limit - this.cachedEntries.length);
const newData = await this.loadEntries(this.cachedEntries.length, this.limit - this.cachedEntries.length);
if (newData.data.length === 0) {
this.hasMore = false;
}

0 comments on commit cbe874c

Please sign in to comment.