diff --git a/demos/src/infinite-scroll/app.component.ts b/demos/src/infinite-scroll/app.component.ts index 7df5efc3bc2..483b7730106 100644 --- a/demos/src/infinite-scroll/app.component.ts +++ b/demos/src/infinite-scroll/app.component.ts @@ -82,7 +82,7 @@ export class ApiDemoApp { infiniteScroll.complete(); if (this.items.length > 90) { - infiniteScroll.enable(false); + infiniteScroll.enabled = false; } }); } diff --git a/src/components/infinite-scroll/infinite-scroll.ts b/src/components/infinite-scroll/infinite-scroll.ts index 5fa1291aca5..03d0c33dd96 100644 --- a/src/components/infinite-scroll/infinite-scroll.ts +++ b/src/components/infinite-scroll/infinite-scroll.ts @@ -131,6 +131,26 @@ 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. + * + * Call `enable = false` to disable the infinite scroll from actively + * trying to receive new data while scrolling. This method is useful + * when it is known that there is no more data that can be added, and + * the infinite scroll is no longer needed. + */ + @Input() + get enabled(): boolean { + return this.state !== STATE_DISABLED; + } + + set enabled(shouldEnable: boolean) { + this.state = (shouldEnable ? STATE_ENABLED : STATE_DISABLED); + this._setListeners(shouldEnable); + } + /** * @output {event} The expression to call when the scroll reaches * the threshold distance. From within your infinite handler, @@ -203,20 +223,6 @@ export class InfiniteScroll { this.state = STATE_ENABLED; } - /** - * Call `enable(false)` to disable the infinite scroll from actively - * trying to receive new data while scrolling. This method is useful - * when it is known that there is no more data that can be added, and - * the infinite scroll is no longer needed. - * @param {boolean} shouldEnable If the infinite scroll should be - * enabled or not. Setting to `false` will remove scroll event listeners - * and hide the display. - */ - enable(shouldEnable: boolean) { - this.state = (shouldEnable ? STATE_ENABLED : STATE_DISABLED); - this._setListeners(shouldEnable); - } - _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 03c4220ff92..8595021b3d3 100644 --- a/src/components/infinite-scroll/test/basic/app-module.ts +++ b/src/components/infinite-scroll/test/basic/app-module.ts @@ -29,7 +29,7 @@ export class E2EPage1 { if (this.items.length > 90) { this.enabled = false; - infiniteScroll.enable(this.enabled); + infiniteScroll.enabled = this.enabled; } }); } @@ -40,7 +40,7 @@ export class E2EPage1 { toggleInfiniteScroll() { this.enabled = !this.enabled; - this.infiniteScroll.enable(this.enabled); + this.infiniteScroll.enabled = this.enabled; } } diff --git a/src/components/infinite-scroll/test/short-list/app-module.ts b/src/components/infinite-scroll/test/short-list/app-module.ts index d1520e66a03..f9bd2e638f2 100644 --- a/src/components/infinite-scroll/test/short-list/app-module.ts +++ b/src/components/infinite-scroll/test/short-list/app-module.ts @@ -26,7 +26,7 @@ export class E2EPage { infiniteScroll.complete(); if (this.items.length > 90) { - infiniteScroll.enable(false); + infiniteScroll.enabled = false; } }); }