Skip to content

Commit

Permalink
cache the results of inputPropChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-smith committed Nov 19, 2017
1 parent 12033e8 commit 34397ac
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/modules/infinite-scroll.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ export class InfiniteScrollDirective
}

ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled }: SimpleChanges) {
if (inputPropChanged(infiniteScrollContainer) || inputPropChanged(infiniteScrollDisabled)) {
var containerChanged: boolean = inputPropChanged(infiniteScrollContainer);
var disabledChanged: boolean = inputPropChanged(infiniteScrollDisabled)

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

if ((!inputPropChanged(infiniteScrollDisabled) && !this.infiniteScrollDisabled) ||
(inputPropChanged(infiniteScrollDisabled) && !infiniteScrollDisabled.currentValue)) {
if ((!disabledChanged && !this.infiniteScrollDisabled) ||
(disabledChanged && !infiniteScrollDisabled.currentValue)) {
this.setup();
}
}
Expand Down

0 comments on commit 34397ac

Please sign in to comment.