Skip to content

Commit fd5cdf0

Browse files
manucorporatbrandyscarney
authored andcommitted
feat(infinite-scroll): it can be enabled/disabled from a ng input (#8385)
closes #8380
1 parent 4964944 commit fd5cdf0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/components/infinite-scroll/infinite-scroll.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ export class InfiniteScroll {
135135
}
136136
}
137137

138+
/**
139+
* @input {boolean} Whether or not the infinite scroll should be
140+
* enabled or not. Setting to `false` will remove scroll event listeners
141+
* and hide the display.
142+
*/
143+
@Input()
144+
set enabled(shouldEnable: boolean) {
145+
this.enable(shouldEnable);
146+
}
147+
138148
/**
139149
* @output {event} The expression to call when the scroll reaches
140150
* the threshold distance. From within your infinite handler,
@@ -221,6 +231,9 @@ export class InfiniteScroll {
221231
this._setListeners(shouldEnable);
222232
}
223233

234+
/**
235+
* @private
236+
*/
224237
_setListeners(shouldListen: boolean) {
225238
if (this._init) {
226239
if (shouldListen) {

src/components/infinite-scroll/test/basic/app-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export class E2EPage1 {
2929

3030
if (this.items.length > 90) {
3131
this.enabled = false;
32-
infiniteScroll.enable(this.enabled);
3332
}
3433
});
3534
}
@@ -40,7 +39,6 @@ export class E2EPage1 {
4039

4140
toggleInfiniteScroll() {
4241
this.enabled = !this.enabled;
43-
this.infiniteScroll.enable(this.enabled);
4442
}
4543
}
4644

src/components/infinite-scroll/test/basic/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</button>
2424
</ion-list>
2525

26-
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" threshold="100px">
26+
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" [enabled]="enabled" threshold="100px">
2727
<ion-infinite-scroll-content
2828
loadingSpinner="bubbles"
2929
loadingText="Loading more data...">

0 commit comments

Comments
 (0)