From 5a5e4e294a8bbd666339d58ac3fdb68df5ca019c Mon Sep 17 00:00:00 2001 From: Ed Opare-Aryee Date: Sun, 18 Feb 2018 12:16:51 +0000 Subject: [PATCH] fix(ScrollCollapse): remove debounce operator when set to 0 for rubber band scrolling --- src/app/scroll-collapse/scroll-collapse.directive.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/scroll-collapse/scroll-collapse.directive.ts b/src/app/scroll-collapse/scroll-collapse.directive.ts index d017239..b4ed5a0 100644 --- a/src/app/scroll-collapse/scroll-collapse.directive.ts +++ b/src/app/scroll-collapse/scroll-collapse.directive.ts @@ -13,7 +13,9 @@ import { takeUntil, bufferCount, map, - startWith + startWith, + distinctUntilChanged, + tap } from 'rxjs/operators'; import { fromEvent } from 'rxjs/observable/fromEvent'; import { merge } from 'rxjs/observable/merge'; @@ -137,9 +139,12 @@ export class ScrollCollapseDirective implements AfterViewInit, OnDestroy { fromEvent(this.windowRef as any, eventData.eventResize) ) .pipe( - debounceTime(this.debounce), + startWith(null), map(() => this.getViewport()), bufferCount(2, 1), + distinctUntilChanged(), + // Do not apply debounce operator if debounce is set to 0 + this.debounce ? debounceTime(this.debounce) : tap(null), takeUntil(this.ngUnsubscribe$) ) .subscribe((events: Viewport[]) =>