mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
Working PTR
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import {Component, View, ElementRef} from 'angular2/angular2';
|
import {Component, View, ElementRef, onInit} from 'angular2/angular2';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
|
|
||||||
@ -7,7 +7,8 @@ import {Ion} from '../ion';
|
|||||||
selector: 'ion-content',
|
selector: 'ion-content',
|
||||||
properties: [
|
properties: [
|
||||||
'parallax'
|
'parallax'
|
||||||
]
|
],
|
||||||
|
lifecycle: [onInit]
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
template: '<div class="scroll-content"><content></content></div>'
|
template: '<div class="scroll-content"><content></content></div>'
|
||||||
@ -15,10 +16,10 @@ import {Ion} from '../ion';
|
|||||||
export class Content extends Ion {
|
export class Content extends Ion {
|
||||||
constructor(elementRef: ElementRef) {
|
constructor(elementRef: ElementRef) {
|
||||||
super(elementRef);
|
super(elementRef);
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
onInit() {
|
||||||
this.scrollElement = elementRef.nativeElement.children[0];
|
this.scrollElement = this.elementRef.nativeElement.children[0];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addScrollEventListener(handler) {
|
addScrollEventListener(handler) {
|
||||||
|
@ -52,5 +52,6 @@ $item-ios-border-color: $list-ios-border-color !default;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.list-ios .item-group-title {
|
.list-ios .item-group-title {
|
||||||
|
// TODO: This doesn't look great when it's a header for the first item
|
||||||
@include hairline(bottom, $item-ios-border-color, $z-index-list-border);
|
@include hairline(bottom, $item-ios-border-color, $z-index-list-border);
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ ion-refresher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.scroll-content.overscroll{
|
.scroll-content.overscroll {
|
||||||
position:fixed;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
-webkit-overflow-scrolling:touch;
|
-webkit-overflow-scrolling:touch;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import {Component, View, NgIf, CSSClass, ElementRef, EventEmitter, Parent} from 'angular2/angular2'
|
import {Component, View, NgIf, CSSClass, ElementRef, EventEmitter, Parent, onInit} from 'angular2/angular2'
|
||||||
|
|
||||||
import {Content} from '../content/content';
|
import {Content} from '../content/content';
|
||||||
|
|
||||||
@ -20,19 +20,20 @@ import {raf, ready, CSS} from 'ionic/util/dom';
|
|||||||
'[class.active]': 'isActive',
|
'[class.active]': 'isActive',
|
||||||
'[class.refreshing]': 'isRefreshing',
|
'[class.refreshing]': 'isRefreshing',
|
||||||
'[class.refreshingTail]': 'isRefreshingTail'
|
'[class.refreshingTail]': 'isRefreshingTail'
|
||||||
}
|
},
|
||||||
|
lifecycle: [onInit]
|
||||||
})
|
})
|
||||||
@View({
|
@View({
|
||||||
template: `<div class="refresher-content refresher-with-text">
|
template: `<div class="refresher-content" [class.refresher-with-text]="pullingText || refreshingText">
|
||||||
<div class="icon-pulling">
|
<div class="icon-pulling">
|
||||||
<i class="icon" [class]="pullingIcon"></i>
|
<i class="icon" [class]="pullingIcon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-pulling" [inner-html]="pullingText"></div>
|
<div class="text-pulling" [inner-html]="pullingText" *ng-if="pullingText"></div>
|
||||||
<div class="icon-refreshing">
|
<div class="icon-refreshing">
|
||||||
<!--<ion-spinner ng-if="showSpinner" icon="{{spinner}}"></ion-spinner>-->
|
<!--<ion-spinner ng-if="showSpinner" icon="{{spinner}}"></ion-spinner>-->
|
||||||
<i class="icon" [class]="refreshingIcon"></i>
|
<i class="icon" [class]="refreshingIcon"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-refreshing" [inner-html]="refreshingText"></div>
|
<div class="text-refreshing" [inner-html]="refreshingText" *ng-if="refreshingText"></div>
|
||||||
</div>`,
|
</div>`,
|
||||||
directives: [NgIf, CSSClass]
|
directives: [NgIf, CSSClass]
|
||||||
})
|
})
|
||||||
@ -49,10 +50,10 @@ export class Refresher {
|
|||||||
this.refresh = new EventEmitter('refresh');
|
this.refresh = new EventEmitter('refresh');
|
||||||
this.starting = new EventEmitter('starting');
|
this.starting = new EventEmitter('starting');
|
||||||
this.pulling = new EventEmitter('pulling');
|
this.pulling = new EventEmitter('pulling');
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
onInit() {
|
||||||
this.initEvents();
|
this.initEvents();
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initEvents() {
|
initEvents() {
|
||||||
@ -73,9 +74,11 @@ export class Refresher {
|
|||||||
this.scrollParent = sp;
|
this.scrollParent = sp;
|
||||||
this.scrollChild = sc;
|
this.scrollChild = sc;
|
||||||
|
|
||||||
if(!util.isDefined(this.pullingIcon)) {
|
util.defaults(this, {
|
||||||
this.pullingIcon = 'ion-android-arrow-down';
|
pullingIcon: 'ion-android-arrow-down',
|
||||||
}
|
refreshingIcon: 'ion-ionic'
|
||||||
|
//refreshingText: 'Updating'
|
||||||
|
})
|
||||||
|
|
||||||
this.showSpinner = !util.isDefined(this.refreshingIcon) && this.spinner != 'none';
|
this.showSpinner = !util.isDefined(this.refreshingIcon) && this.spinner != 'none';
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ export class Refresher {
|
|||||||
start() {
|
start() {
|
||||||
// startCallback
|
// startCallback
|
||||||
this.isRefreshing = true;
|
this.isRefreshing = true;
|
||||||
this.refresh.next();
|
this.refresh.next(this);
|
||||||
//$scope.$onRefresh();
|
//$scope.$onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +167,29 @@ export class Refresher {
|
|||||||
this.ele.classList.add('invisible');
|
this.ele.classList.add('invisible');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tail() {
|
||||||
|
// tailCallback
|
||||||
|
this.ele.classList.add('refreshing-tail');
|
||||||
|
}
|
||||||
|
|
||||||
|
complete() {
|
||||||
|
setTimeout(() => {
|
||||||
|
raf(this.tail.bind(this));
|
||||||
|
|
||||||
|
// scroll back to home during tail animation
|
||||||
|
this.scrollTo(0, this.scrollTime, this.deactivate.bind(this));
|
||||||
|
|
||||||
|
// return to native scrolling after tail animation has time to finish
|
||||||
|
setTimeout(() => {
|
||||||
|
if(this.isOverscrolling) {
|
||||||
|
this.isOverscrolling = false;
|
||||||
|
this.setScrollLock(false);
|
||||||
|
}
|
||||||
|
}, this.scrollTime);
|
||||||
|
|
||||||
|
}, this.scrollTime);
|
||||||
|
}
|
||||||
|
|
||||||
scrollTo(Y, duration, callback) {
|
scrollTo(Y, duration, callback) {
|
||||||
// scroll animation loop w/ easing
|
// scroll animation loop w/ easing
|
||||||
// credit https://gist.github.com/dezinezync/5487119
|
// credit https://gist.github.com/dezinezync/5487119
|
||||||
|
@ -11,8 +11,12 @@ class MyApp {
|
|||||||
constructor() {
|
constructor() {
|
||||||
console.log('IonicApp Start')
|
console.log('IonicApp Start')
|
||||||
}
|
}
|
||||||
doRefresh() {
|
doRefresh(refresher) {
|
||||||
console.log('DOREFRESH')
|
console.log('DOREFRESH', refresher)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
refresher.complete();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
doStarting() {
|
doStarting() {
|
||||||
console.log('DOSTARTING');
|
console.log('DOSTARTING');
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ion-toolbar><ion-title>Pull To Refresh</ion-title></ion-toolbar>
|
<ion-toolbar><ion-title>Pull To Refresh</ion-title></ion-toolbar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<ion-refresher (starting)="doStarting()" (refresh)="doRefresh()" (pulling)="doPulling($event, amt)">
|
<ion-refresher (starting)="doStarting()" (refresh)="doRefresh($event, refresher)" (pulling)="doPulling($event, amt)">
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<f></f>
|
<f></f>
|
||||||
<f></f>
|
<f></f>
|
||||||
@ -16,7 +16,6 @@
|
|||||||
</ion-view>
|
</ion-view>
|
||||||
<style>
|
<style>
|
||||||
f { display: block; height: 400px; width: 100%; background-color: #387ef5; margin-bottom: 15px; }
|
f { display: block; height: 400px; width: 100%; background-color: #387ef5; margin-bottom: 15px; }
|
||||||
ion-refresher { background-color: red; }
|
|
||||||
#counter {
|
#counter {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -8,8 +8,11 @@ $toolbar-order: (
|
|||||||
secondary: 40
|
secondary: 40
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$toolbar-zindex: 2;
|
||||||
|
|
||||||
|
|
||||||
ion-toolbar {
|
ion-toolbar {
|
||||||
|
z-index: $toolbar-zindex;
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
Reference in New Issue
Block a user