mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +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
|
* @output {event} The expression to call when the scroll reaches
|
||||||
* the threshold distance. From within your infinite handler,
|
* the threshold distance. From within your infinite handler,
|
||||||
@ -221,6 +231,9 @@ export class InfiniteScroll {
|
|||||||
this._setListeners(shouldEnable);
|
this._setListeners(shouldEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
_setListeners(shouldListen: boolean) {
|
_setListeners(shouldListen: boolean) {
|
||||||
if (this._init) {
|
if (this._init) {
|
||||||
if (shouldListen) {
|
if (shouldListen) {
|
||||||
|
@ -29,7 +29,6 @@ export class E2EPage1 {
|
|||||||
|
|
||||||
if (this.items.length > 90) {
|
if (this.items.length > 90) {
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
infiniteScroll.enable(this.enabled);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -40,7 +39,6 @@ export class E2EPage1 {
|
|||||||
|
|
||||||
toggleInfiniteScroll() {
|
toggleInfiniteScroll() {
|
||||||
this.enabled = !this.enabled;
|
this.enabled = !this.enabled;
|
||||||
this.infiniteScroll.enable(this.enabled);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" threshold="100px">
|
<ion-infinite-scroll (ionInfinite)="doInfinite($event)" [enabled]="enabled" threshold="100px">
|
||||||
<ion-infinite-scroll-content
|
<ion-infinite-scroll-content
|
||||||
loadingSpinner="bubbles"
|
loadingSpinner="bubbles"
|
||||||
loadingText="Loading more data...">
|
loadingText="Loading more data...">
|
||||||
|
Reference in New Issue
Block a user