Autoload when reach bottom

This commit is contained in:
2017-05-04 21:45:38 +02:00
parent 9793bc8763
commit 1abf0b6a0f
2 changed files with 7 additions and 1 deletions

View File

@@ -37,7 +37,7 @@
</tbody>
</table>
<button type="button" *ngIf="more" class="btn btn-default" aria-label="More" (click)="loadSongs()">
<button type="button" *ngIf="more" class="btn btn-default" aria-label="More" (click)="loadSongs()" (window:scroll)="onScroll($event)">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> More...
</button>

View File

@@ -57,4 +57,10 @@ export class AlbumComponent implements OnInit {
scrollTop(): void {
window.scrollTo(0,0);
}
onScroll(event: any) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
this.loadSongs();
}
}
}