diff --git a/demos/src/infinite-scroll/app.component.ts b/demos/src/infinite-scroll/app.component.ts index 7df5efc3bc2..e851d51f26e 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.setEnable(false); } }); } diff --git a/src/components/infinite-scroll/infinite-scroll.ts b/src/components/infinite-scroll/infinite-scroll.ts index 5fa1291aca5..ad89087f37d 100644 --- a/src/components/infinite-scroll/infinite-scroll.ts +++ b/src/components/infinite-scroll/infinite-scroll.ts @@ -131,6 +131,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.setEnable(shouldEnable); + } + /** * @output {event} The expression to call when the scroll reaches * the threshold distance. From within your infinite handler, @@ -212,11 +222,14 @@ export class InfiniteScroll { * enabled or not. Setting to `false` will remove scroll event listeners * and hide the display. */ - enable(shouldEnable: boolean) { + setEnable(shouldEnable: boolean) { this.state = (shouldEnable ? STATE_ENABLED : STATE_DISABLED); 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 03c4220ff92..999c57e7f6d 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.setEnable(this.enabled); } }); } @@ -40,7 +40,7 @@ export class E2EPage1 { toggleInfiniteScroll() { this.enabled = !this.enabled; - this.infiniteScroll.enable(this.enabled); + this.infiniteScroll.setEnable(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..d8206f519fe 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.setEnable(false); } }); }