Skip to content

Commit 3efb33d

Browse files
committed
fix(refresher): PTR doesn't break after scrolling. Fixes #4753
1 parent f11b6a8 commit 3efb33d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Diff for: js/angular/controller/refresherController.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ IonicModule
4949
}
5050

5151
function handleTouchend() {
52+
// reset Y
53+
startY = null;
5254
// if this wasn't an overscroll, get out immediately
5355
if (!canOverscroll && !isDragging) {
5456
return;
5557
}
56-
// reset Y
57-
startY = null;
5858
// the user has overscrolled but went back to native scrolling
5959
if (!isDragging) {
6060
dragOffset = 0;
@@ -104,6 +104,8 @@ IonicModule
104104
// if we've dragged up and back down in to native scroll territory
105105
if (deltaY - dragOffset <= 0 || scrollParent.scrollTop !== 0) {
106106

107+
console.log('NOT PULLING', deltaY, dragOffset, scrollParent.scrollTop);
108+
107109
if (isOverscrolling) {
108110
isOverscrolling = false;
109111
setScrollLock(false);
@@ -120,6 +122,7 @@ IonicModule
120122
return;
121123

122124
} else if (deltaY > 0 && scrollParent.scrollTop === 0 && !isOverscrolling) {
125+
console.log('PULLING', deltaY, dragOffset, scrollParent.scrollTop, isOverscrolling);
123126
// starting overscroll, but drag started below scrollTop 0, so we need to offset the position
124127
dragOffset = deltaY;
125128
}

Diff for: test/unit/angular/controller/refreshController.unit.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ describe('$ionicRefresh Controller', function() {
4343
}).toThrow();
4444
});
4545

46-
it('should oversroll using CSS transforms', function() {
46+
it('should overscroll using CSS transforms', function() {
4747
setup();
4848

49+
function getTy(el) {
50+
return parseInt(el.style[ionic.CSS.TRANSFORM].replace('translateY(', ''));
51+
}
52+
4953
ctrl.__handleTouchmove(evt(0));
5054
ctrl.__handleTouchmove(evt(10));
5155
ctrl.__handleTouchmove(evt(20));
52-
expect(ctrl.__getScrollChild().style[ionic.CSS.TRANSFORM]).toBe('translateY(3px)');
56+
expect(getTy(ctrl.__getScrollChild())).toBe(3);
5357
expect(ctrl.__getScrollChild().classList.contains('overscroll')).toBe(true);
5458
expect(refresher.classList.contains('invisible')).toBe(false);
5559
});
@@ -70,6 +74,9 @@ describe('$ionicRefresh Controller', function() {
7074
});
7175

7276
it('should activate and deactivate when dragging past activation threshold', function() {
77+
function getTy(el) {
78+
return parseInt(el.style[ionic.CSS.TRANSFORM].replace('translateY(', ''));
79+
}
7380
setup();
7481
var domMethods = ctrl.getRefresherDomMethods();
7582
spyOn(domMethods, 'activate');
@@ -78,7 +85,7 @@ describe('$ionicRefresh Controller', function() {
7885
ctrl.__handleTouchmove(evt(0));
7986
ctrl.__handleTouchmove(evt(10));
8087
ctrl.__handleTouchmove(evt(300));
81-
expect(ctrl.__getScrollChild().style[ionic.CSS.TRANSFORM]).toBe('translateY(96px)');
88+
expect(getTy(ctrl.__getScrollChild())).toBe(96);
8289
expect(ctrl.__getScrollChild().classList.contains('overscroll')).toBe(true);
8390
expect(refresher.classList.contains('invisible')).toBe(false);
8491
expect(refresher.classList.contains('active')).toBe(true);

0 commit comments

Comments
 (0)