Skip to content

Commit

Permalink
fix(infinitescroll): only show spinner when loading
Browse files Browse the repository at this point in the history
Closes #5690
  • Loading branch information
adamdbradley committed Mar 4, 2016
1 parent c96af06 commit 7ee0b52
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ionic/components/infinite-scroll/infinite-scroll.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ion-infinite-scroll-content {
}

.infinite-loading {
opacity: 0;
width: 100%;
margin: $infinite-scroll-loading-margin;
}
Expand All @@ -39,6 +40,10 @@ ion-infinite-scroll-content {
// Infinite Scroll Content States
// --------------------------------------------------

ion-infinite-scroll-content[state=disabled] .infinite-loading {
ion-infinite-scroll-content[state=loading] .infinite-loading {
opacity: 1;
}

ion-infinite-scroll-content[state=disabled] {
display: none;
}
49 changes: 49 additions & 0 deletions ionic/components/infinite-scroll/test/short-list/index.ts
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 ionic/components/infinite-scroll/test/short-list/main.html
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>

0 comments on commit 7ee0b52

Please sign in to comment.