mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(refresher): allow refresher content customization
Breaking Change: ## Refresher: - `<ion-refresher>` now takes a child `<ion-refresher-content>` component. - Custom refresh content components can now be replaced for Ionic's default refresher content. - Properties `pullingIcon`, `pullingText` and `refreshingText` have been moved to the `<ion-refresher-content>` component. - `spinner` property has been renamed to `refreshingSpinner` and now goes on the `<ion-refresher-content>` component. - `refreshingIcon` property is no longer an input, but instead `refreshingSpinner` should be used. Was: ``` <ion-refresher (refresh)="doRefresh($event)" pullingIcon="arrow-dropdown"> </ion-refresher> ``` Now: ``` <ion-refresher (refresh)="doRefresh($event)"> <ion-refresher-content pullingIcon="arrow-dropdown"></ion-refresher-content> </ion-refresher> ```
This commit is contained in:
85
ionic/components/refresher/test/basic/index.ts
Normal file
85
ionic/components/refresher/test/basic/index.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
import {App} from 'ionic-angular';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EApp {
|
||||
items = [];
|
||||
|
||||
constructor() {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
this.items.push( getRandomData() );
|
||||
}
|
||||
}
|
||||
|
||||
doRefresh(refresher) {
|
||||
console.log('Begin async operation');
|
||||
|
||||
getAsyncData().then(newData => {
|
||||
for (var i = 0; i < newData.length; i++) {
|
||||
this.items.unshift( newData[i] );
|
||||
}
|
||||
|
||||
console.log('Finished receiving data, async operation complete');
|
||||
refresher.endRefreshing();
|
||||
});
|
||||
}
|
||||
|
||||
doStart(refresher) {
|
||||
console.log('Refresher, start');
|
||||
}
|
||||
|
||||
doPulling(refresher) {
|
||||
console.log('Pulling', refresher.progress);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getAsyncData() {
|
||||
// async return mock data
|
||||
return new Promise(resolve => {
|
||||
|
||||
setTimeout(() => {
|
||||
let data = [];
|
||||
for (var i = 0; i < 3; i++) {
|
||||
data.push( getRandomData() );
|
||||
}
|
||||
|
||||
resolve(data);
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function getRandomData() {
|
||||
let i = Math.floor( Math.random() * data.length );
|
||||
return data[i];
|
||||
}
|
||||
|
||||
const data = [
|
||||
'Fast Times at Ridgemont High',
|
||||
'Peggy Sue Got Married',
|
||||
'Raising Arizona',
|
||||
'Moonstruck',
|
||||
'Fire Birds',
|
||||
'Honeymoon in Vegas',
|
||||
'Amos & Andrew',
|
||||
'It Could Happen to You',
|
||||
'Trapped in Paradise',
|
||||
'Leaving Las Vegas',
|
||||
'The Rock',
|
||||
'Con Air',
|
||||
'Face/Off',
|
||||
'City of Angels',
|
||||
'Gone in Sixty Seconds',
|
||||
'The Family Man',
|
||||
'Windtalkers',
|
||||
'Matchstick Men',
|
||||
'National Treasure',
|
||||
'Ghost Rider',
|
||||
'Grindhouse',
|
||||
'Next',
|
||||
'Kick-Ass',
|
||||
'Drive Angry'
|
||||
];
|
||||
21
ionic/components/refresher/test/basic/main.html
Normal file
21
ionic/components/refresher/test/basic/main.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<ion-toolbar><ion-title>Pull To Refresh</ion-title></ion-toolbar>
|
||||
|
||||
<ion-content>
|
||||
|
||||
<ion-refresher (start)="doStart($event)" (pulling)="doPulling($event)" (refresh)="doRefresh($event)">
|
||||
|
||||
<ion-refresher-content
|
||||
pullingText="Pull to refresh..."
|
||||
refreshingSpinner="bubbles"
|
||||
refreshingText="Refreshing...">
|
||||
</ion-refresher-content>
|
||||
|
||||
</ion-refresher>
|
||||
|
||||
<ion-list>
|
||||
<ion-item *ngFor="#item of items">
|
||||
{{ item }}
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
|
||||
</ion-content>
|
||||
Reference in New Issue
Block a user