From fd5cdf05977b353bb04b3245e5155355071785a0 Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 12 Oct 2016 19:25:26 +0200 Subject: [PATCH] feat(infinite-scroll): it can be enabled/disabled from a ng input (#8385) closes #8380 --- src/components/infinite-scroll/infinite-scroll.ts | 13 +++++++++++++ .../infinite-scroll/test/basic/app-module.ts | 2 -- src/components/infinite-scroll/test/basic/main.html | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/infinite-scroll/infinite-scroll.ts b/src/components/infinite-scroll/infinite-scroll.ts index 07219d6854..63505b215d 100644 --- a/src/components/infinite-scroll/infinite-scroll.ts +++ b/src/components/infinite-scroll/infinite-scroll.ts @@ -135,6 +135,16 @@ export class InfiniteScroll { } } + /** + * @input {boolean} Whether or not the infinite scroll should be + * enabled or not. Setting to `false` will remove scroll event listeners + * and hide the display. + */ + @Input() + set enabled(shouldEnable: boolean) { + this.enable(shouldEnable); + } + /** * @output {event} The expression to call when the scroll reaches * the threshold distance. From within your infinite handler, @@ -221,6 +231,9 @@ export class InfiniteScroll { this._setListeners(shouldEnable); } + /** + * @private + */ _setListeners(shouldListen: boolean) { if (this._init) { if (shouldListen) { diff --git a/src/components/infinite-scroll/test/basic/app-module.ts b/src/components/infinite-scroll/test/basic/app-module.ts index 03c4220ff9..804057a61d 100644 --- a/src/components/infinite-scroll/test/basic/app-module.ts +++ b/src/components/infinite-scroll/test/basic/app-module.ts @@ -29,7 +29,6 @@ export class E2EPage1 { if (this.items.length > 90) { this.enabled = false; - infiniteScroll.enable(this.enabled); } }); } @@ -40,7 +39,6 @@ export class E2EPage1 { toggleInfiniteScroll() { this.enabled = !this.enabled; - this.infiniteScroll.enable(this.enabled); } } diff --git a/src/components/infinite-scroll/test/basic/main.html b/src/components/infinite-scroll/test/basic/main.html index 7e6be1d3b1..c287b7a60d 100644 --- a/src/components/infinite-scroll/test/basic/main.html +++ b/src/components/infinite-scroll/test/basic/main.html @@ -23,7 +23,7 @@ - +