From 2c6bbd97d351d507aec1f6e98ab875aa13a7a2e2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Mar 2018 09:21:34 +0100 Subject: [PATCH] Improve infinite scroll --- client/src/app/shared/video/infinite-scroller.directive.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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