1
0
Fork 0

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

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