Skip to content

Commit

Permalink
fix(ScrollCollapse): remove debounce operator when set to 0 for rubbe…
Browse files Browse the repository at this point in the history
…r band scrolling
  • Loading branch information
edoparearyee committed Feb 19, 2018
1 parent 9c87d87 commit 5a5e4e2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/scroll-collapse/scroll-collapse.directive.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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[]) =>
Expand Down

0 comments on commit 5a5e4e2

Please sign in to comment.