-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(infinitescroll): only show spinner when loading
Closes #5690
- Loading branch information
1 parent
c96af06
commit 7ee0b52
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import {App, InfiniteScroll} from 'ionic-angular'; | ||
|
||
|
||
@App({ | ||
templateUrl: 'main.html' | ||
}) | ||
class E2EApp { | ||
items = []; | ||
|
||
constructor() { | ||
for (var i = 0; i < 5; i++) { | ||
this.items.push( this.items.length ); | ||
} | ||
} | ||
|
||
doInfinite(infiniteScroll: InfiniteScroll) { | ||
console.log('Begin async operation'); | ||
|
||
getAsyncData().then(newData => { | ||
for (var i = 0; i < newData.length; i++) { | ||
this.items.push( this.items.length ); | ||
} | ||
|
||
console.log('Finished receiving data, async operation complete'); | ||
infiniteScroll.complete(); | ||
|
||
if (this.items.length > 90) { | ||
infiniteScroll.enable(false); | ||
} | ||
}); | ||
} | ||
|
||
} | ||
|
||
function getAsyncData(): Promise<number[]> { | ||
// async return mock data | ||
return new Promise(resolve => { | ||
|
||
setTimeout(() => { | ||
let data = []; | ||
for (var i = 0; i < 30; i++) { | ||
data.push(i); | ||
} | ||
|
||
resolve(data); | ||
}, 500); | ||
|
||
}); | ||
} |
18 changes: 18 additions & 0 deletions
18
ionic/components/infinite-scroll/test/short-list/main.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<ion-toolbar><ion-title>Infinite Scroll</ion-title></ion-toolbar> | ||
|
||
<ion-content> | ||
|
||
<ion-list> | ||
<ion-item *ngFor="#item of items"> | ||
{{ item }} | ||
</ion-item> | ||
</ion-list> | ||
|
||
<ion-infinite-scroll (infinite)="doInfinite($event)" threshold="100px"> | ||
<ion-infinite-scroll-content | ||
loadingSpinner="bubbles" | ||
loadingText="Loading more data..."> | ||
</ion-infinite-scroll-content> | ||
</ion-infinite-scroll> | ||
|
||
</ion-content> |