Skip to content

Commit

Permalink
Merge pull request orizens#196 from dylan-smith/infiniteScrollDisable…
Browse files Browse the repository at this point in the history
…d_Changes

Allow changing infiniteScrollDisabled
  • Loading branch information
orizens authored Nov 27, 2017
2 parents 7a793c4 + a3f9d15 commit 5a8182a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/modules/infinite-scroll.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@ export class InfiniteScrollDirective
constructor(private element: ElementRef, private zone: NgZone) {}

ngAfterViewInit() {
this.setup();
if (!this.infiniteScrollDisabled) {
this.setup();
}
}

ngOnChanges({ infiniteScrollContainer, infiniteScrollDistance }: SimpleChanges) {
if (inputPropChanged(infiniteScrollContainer) || inputPropChanged(infiniteScrollDistance)) {
ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled, infiniteScrollDistance }: SimpleChanges) {
const containerChanged = inputPropChanged(infiniteScrollContainer);
const disabledChanged = inputPropChanged(infiniteScrollDisabled);
const distanceChanged = inputPropChanged(infiniteScrollDistance);
const shouldSetup = (!disabledChanged && !this.infiniteScrollDisabled) ||
(disabledChanged && !infiniteScrollDisabled.currentValue) || distanceChanged;

if (containerChanged || disabledChanged || distanceChanged) {
this.destroyScroller();
this.setup();

if (shouldSetup) {
this.setup();
}
}
}

Expand Down

0 comments on commit 5a8182a

Please sign in to comment.