mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
feat(infinite-scroll): it can be enabled/disabled from a ng input (#8385)
closes #8380
This commit is contained in:

committed by
Brandy Carney

parent
4964944056
commit
fd5cdf0597
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
</button>
|
||||
</ion-list>
|
||||
|
||||
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" threshold="100px">
|
||||
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" [enabled]="enabled" threshold="100px">
|
||||
<ion-infinite-scroll-content
|
||||
loadingSpinner="bubbles"
|
||||
loadingText="Loading more data...">
|
||||
|
Reference in New Issue
Block a user