Improve infinite scroll

This commit is contained in:
Chocobozzz 2018-03-09 09:21:34 +01:00
parent 0647f472bc
commit 2c6bbd97d3
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 2 additions and 1 deletions

View File

@ -38,12 +38,13 @@ export class InfiniteScrollerDirective implements OnInit {
initialize () {
// Emit the last value
const throttleOptions = { leading: false, trailing: true }
const throttleOptions = { leading: true, trailing: true }
const scrollObservable = fromEvent(window, 'scroll')
.startWith(true)
.throttleTime(200, undefined, throttleOptions)
.map(() => ({ current: window.scrollY, maximumScroll: document.body.clientHeight - window.innerHeight }))
.distinctUntilChanged((o1, o2) => o1.current === o2.current)
.share()
// Scroll Down