From 2d3395331da3bed9b76e3919d05ca4914a55dc29 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 23 Oct 2017 13:17:15 -0500 Subject: [PATCH 1/6] Allow changing infiniteScrollDisabled If infiniteScrollDisabled is changed, call setup() again to recreate the scroller. --- src/modules/infinite-scroll.directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index 0cea3867..14dd9ac2 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -43,8 +43,8 @@ export class InfiniteScrollDirective this.setup(); } - ngOnChanges({ infiniteScrollContainer }: SimpleChanges) { - if (inputPropChanged(infiniteScrollContainer)) { + ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled }: SimpleChanges) { + if (inputPropChanged(infiniteScrollContainer) || inputPropChanged(infiniteScrollDisabled)) { this.destroyScroller(); this.setup(); } From 88a3b21177142098e18fac9325cd277a8abb4cb4 Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Mon, 23 Oct 2017 14:35:15 -0500 Subject: [PATCH 2/6] only create scroller when enabled only call setup when disabled = false Note: I haven't tested this yet, but putting it here for review --- src/modules/infinite-scroll.directive.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index 14dd9ac2..0aa2369a 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -40,13 +40,19 @@ export class InfiniteScrollDirective constructor(private element: ElementRef, private zone: NgZone) {} ngAfterViewInit() { - this.setup(); + if (!this.infiniteScrollDisabled) { + this.setup(); + } } ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled }: SimpleChanges) { if (inputPropChanged(infiniteScrollContainer) || inputPropChanged(infiniteScrollDisabled)) { this.destroyScroller(); - this.setup(); + + if ((!inputPropChanged(infiniteScrollDisabled) && !this.infiniteScrollDisabled)) || + (inputPropChanged(infiniteScrollDisabled) && !infiniteScrollDisabled.currentValue)) { + this.setup(); + } } } From 12033e82eec993e8e1080816ccb8ccffa0ffde9b Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sat, 28 Oct 2017 17:12:46 -0500 Subject: [PATCH 3/6] Typo - extra closing paren --- src/modules/infinite-scroll.directive.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index 0aa2369a..378e50cf 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -49,7 +49,7 @@ export class InfiniteScrollDirective if (inputPropChanged(infiniteScrollContainer) || inputPropChanged(infiniteScrollDisabled)) { this.destroyScroller(); - if ((!inputPropChanged(infiniteScrollDisabled) && !this.infiniteScrollDisabled)) || + if ((!inputPropChanged(infiniteScrollDisabled) && !this.infiniteScrollDisabled) || (inputPropChanged(infiniteScrollDisabled) && !infiniteScrollDisabled.currentValue)) { this.setup(); } From 34397ac89af3031b4d14f784d7d934d0d174176a Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sun, 29 Oct 2017 13:31:15 -0500 Subject: [PATCH 4/6] cache the results of inputPropChanged --- src/modules/infinite-scroll.directive.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index 378e50cf..c5a5e753 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -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(); } } From c6856ecec222af15834fa6c25bed2de4678b8e0a Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sun, 19 Nov 2017 13:31:29 -0600 Subject: [PATCH 5/6] changed var to const as per PR feedback --- src/modules/infinite-scroll.directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index c5a5e753..c40c2115 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -46,8 +46,8 @@ export class InfiniteScrollDirective } ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled }: SimpleChanges) { - var containerChanged: boolean = inputPropChanged(infiniteScrollContainer); - var disabledChanged: boolean = inputPropChanged(infiniteScrollDisabled) + const containerChanged: boolean = inputPropChanged(infiniteScrollContainer); + const disabledChanged: boolean = inputPropChanged(infiniteScrollDisabled) if (containerChanged || disabledChanged) { this.destroyScroller(); From 61660e8b72403a36ab8e8a0b06fc3dabdf3f1a3c Mon Sep 17 00:00:00 2001 From: Dylan Smith Date: Sun, 19 Nov 2017 13:36:12 -0600 Subject: [PATCH 6/6] removed unnecessary typing --- src/modules/infinite-scroll.directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/infinite-scroll.directive.ts b/src/modules/infinite-scroll.directive.ts index c40c2115..1aa067da 100644 --- a/src/modules/infinite-scroll.directive.ts +++ b/src/modules/infinite-scroll.directive.ts @@ -46,8 +46,8 @@ export class InfiniteScrollDirective } ngOnChanges({ infiniteScrollContainer, infiniteScrollDisabled }: SimpleChanges) { - const containerChanged: boolean = inputPropChanged(infiniteScrollContainer); - const disabledChanged: boolean = inputPropChanged(infiniteScrollDisabled) + const containerChanged = inputPropChanged(infiniteScrollContainer); + const disabledChanged = inputPropChanged(infiniteScrollDisabled) if (containerChanged || disabledChanged) { this.destroyScroller();