Skip to content

Commit

Permalink
fix(scroll): canOverscroll was set to false which prevented PTR from …
Browse files Browse the repository at this point in the history
…ever working

It’s still finishing the PTR before the complete is called though

References #5207
  • Loading branch information
brandyscarney committed Jan 26, 2016
1 parent adce1e5 commit e4b2006
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
18 changes: 9 additions & 9 deletions ionic/components/scroll/pull-to-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class Refresher {
private _touchMoveListener;
private _touchEndListener;
private _handleScrollListener;

isActive: boolean;
isDragging: boolean = false;
isOverscrolling: boolean = false;
Expand All @@ -94,7 +94,7 @@ export class Refresher {
ptrThreshold: number = 0;
activated: boolean = false;
scrollTime: number = 500;
canOverscroll: boolean = false;
canOverscroll: boolean = true;
startY;
deltaY;
scrollHost;
Expand All @@ -103,18 +103,18 @@ export class Refresher {
showSpinner: boolean;
isRefreshing: boolean;
isRefreshingTail: boolean;

@Input() pullingIcon: string;
@Input() pullingText: string;
@Input() refreshingIcon: string;
@Input() refreshingText: string;
@Input() spinner: string;

@Output() pulling: EventEmitter<any> = new EventEmitter();
@Output() refresh: EventEmitter<any> = new EventEmitter();
@Output() starting: EventEmitter<any> = new EventEmitter();


constructor(
@Host() private content: Content,
element: ElementRef
Expand Down Expand Up @@ -146,7 +146,7 @@ export class Refresher {
this._touchMoveListener = this._handleTouchMove.bind(this);
this._touchEndListener = this._handleTouchEnd.bind(this);
this._handleScrollListener = this._handleScroll.bind(this);

sc.addEventListener('touchmove', this._touchMoveListener);
sc.addEventListener('touchend', this._touchEndListener);
sc.addEventListener('scroll', this._handleScrollListener);
Expand Down Expand Up @@ -389,7 +389,7 @@ export class Refresher {
}

this.isDragging = true;

// overscroll according to the user's drag so far
this.overscroll( Math.round((this.deltaY - this.dragOffset) / 3) );

Expand All @@ -400,7 +400,7 @@ export class Refresher {
if (!this.activated && this.lastOverscroll > this.ptrThreshold) {
this.activated = true;
raf(this.activate.bind(this));

} else if (this.activated && this.lastOverscroll < this.ptrThreshold) {
this.activated = false;
raf(this.deactivate.bind(this));
Expand Down
5 changes: 3 additions & 2 deletions ionic/components/scroll/test/pull-to-refresh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {App} from 'ionic/ionic';
@App({
templateUrl: 'main.html'
})
class MyApp {
class E2EApp {

doRefresh(refresher) {
console.log('DOREFRESH', refresher)

setTimeout(() => {
refresher.complete();
})
console.log("Complete");
}, 5000);
}

doStarting() {
Expand Down
40 changes: 17 additions & 23 deletions ionic/components/scroll/test/pull-to-refresh/main.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
<!-- <ion-view nav-title="Pull to refresh"> -->
<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-refresher (starting)="doStarting()" (refresh)="doRefresh($event, refresher)" (pulling)="doPulling($event, amt)">
</ion-refresher>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
</ion-content>
<ion-content>
<ion-refresher
(starting)="doStarting($event)"
(refresh)="doRefresh($event, refresher)"
(pulling)="doPulling($event, amt)">
</ion-refresher>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
<f></f>
</ion-content>

<!-- </ion-view> -->
<style>
f { display: block; height: 400px; width: 100%; background-color: #387ef5; margin-bottom: 15px; }
#counter {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 20px;
background-color: rgba(0,0,0,0.4);
z-index: 5;
f {
display: block; height: 400px; width: 100%; background-color: #387ef5; margin-bottom: 15px;
}
</style>

0 comments on commit e4b2006

Please sign in to comment.