From: Chocobozzz Date: Fri, 9 Mar 2018 08:21:34 +0000 (+0100) Subject: Improve infinite scroll X-Git-Tag: v1.0.0-alpha.6~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2c6bbd97d351d507aec1f6e98ab875aa13a7a2e2;p=oweals%2Fpeertube.git Improve infinite scroll --- diff --git a/client/src/app/shared/video/infinite-scroller.directive.ts b/client/src/app/shared/video/infinite-scroller.directive.ts index ed49a9e81..e0f9f4f83 100644 --- a/client/src/app/shared/video/infinite-scroller.directive.ts +++ b/client/src/app/shared/video/infinite-scroller.directive.ts @@ -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