@@ -687,13 +687,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
687
687
688
688
self . resetScrollView = function ( e ) {
689
689
//return scrollview to original height once keyboard has hidden
690
- if ( self . isScrolledIntoView ) {
691
- self . isScrolledIntoView = false ;
692
- container . style . height = "" ;
693
- container . style . overflow = "" ;
694
- self . resize ( ) ;
695
- ionic . scroll . isScrolling = false ;
696
- }
690
+ self . isScrolledIntoView = false ;
691
+ container . style . height = "" ;
692
+ container . style . overflow = "" ;
693
+ self . resize ( ) ;
694
+ ionic . scroll . isScrolling = false ;
697
695
} ;
698
696
699
697
//Broadcasted when keyboard is shown on some platforms.
@@ -1116,8 +1114,6 @@ ionic.views.Scroll = ionic.views.View.inherit({
1116
1114
} ,
1117
1115
1118
1116
resize : function ( ) {
1119
- if ( ! this . __container || ! this . options ) return ;
1120
-
1121
1117
// Update Scroller dimensions for changed content
1122
1118
// Add padding to bottom of content
1123
1119
this . setDimensions (
@@ -1286,17 +1282,21 @@ ionic.views.Scroll = ionic.views.View.inherit({
1286
1282
* @param startCallback {Function} Callback to execute to start the real async refresh action. Call {@link #finishPullToRefresh} after finish of refresh.
1287
1283
* @param showCallback {Function} Callback to execute when the refresher should be shown. This is for showing the refresher during a negative scrollTop.
1288
1284
* @param hideCallback {Function} Callback to execute when the refresher should be hidden. This is for hiding the refresher when it's behind the nav bar.
1285
+ * @param tailCallback {Function} Callback to execute just before the refresher returns to it's original state. This is for zooming out the refresher.
1289
1286
*/
1290
- activatePullToRefresh : function ( height , activateCallback , deactivateCallback , startCallback , showCallback , hideCallback ) {
1287
+ activatePullToRefresh : function ( height , activateCallback , deactivateCallback , startCallback , showCallback , hideCallback , tailCallback ) {
1291
1288
1292
1289
var self = this ;
1293
1290
1294
1291
self . __refreshHeight = height ;
1295
- self . __refreshActivate = activateCallback ;
1296
- self . __refreshDeactivate = deactivateCallback ;
1297
- self . __refreshStart = startCallback ;
1298
- self . __refreshShow = showCallback ;
1299
- self . __refreshHide = hideCallback ;
1292
+ self . __refreshActivate = function ( ) { ionic . requestAnimationFrame ( activateCallback ) ; } ;
1293
+ self . __refreshDeactivate = function ( ) { ionic . requestAnimationFrame ( deactivateCallback ) ; } ;
1294
+ self . __refreshStart = function ( ) { ionic . requestAnimationFrame ( startCallback ) ; } ;
1295
+ self . __refreshShow = function ( ) { ionic . requestAnimationFrame ( showCallback ) ; } ;
1296
+ self . __refreshHide = function ( ) { ionic . requestAnimationFrame ( hideCallback ) ; } ;
1297
+ self . __refreshTail = function ( ) { ionic . requestAnimationFrame ( tailCallback ) ; } ;
1298
+ self . __refreshTailTime = 100 ;
1299
+ self . __minSpinTime = 600 ;
1300
1300
} ,
1301
1301
1302
1302
@@ -1308,6 +1308,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
1308
1308
// We don't need to normalize scrollLeft, zoomLevel, etc. here because we only y-scrolling when pull-to-refresh is enabled
1309
1309
this . __publish ( this . __scrollLeft , - this . __refreshHeight , this . __zoomLevel , true ) ;
1310
1310
1311
+ var d = new Date ( ) ;
1312
+ self . refreshStartTime = d . getTime ( ) ;
1313
+
1311
1314
if ( this . __refreshStart ) {
1312
1315
this . __refreshStart ( ) ;
1313
1316
}
@@ -1320,14 +1323,25 @@ ionic.views.Scroll = ionic.views.View.inherit({
1320
1323
finishPullToRefresh : function ( ) {
1321
1324
1322
1325
var self = this ;
1323
-
1324
- self . __refreshActive = false ;
1325
- if ( self . __refreshDeactivate ) {
1326
- self . __refreshDeactivate ( ) ;
1326
+ // delay to make sure the spinner has a chance to spin for a split second before it's dismissed
1327
+ var d = new Date ( ) ;
1328
+ var delay = 0 ;
1329
+ if ( self . refreshStartTime + self . __minSpinTime > d . getTime ( ) ) {
1330
+ delay = self . refreshStartTime + self . __minSpinTime - d . getTime ( ) ;
1327
1331
}
1332
+ setTimeout ( function ( ) {
1333
+ if ( self . __refreshTail ) {
1334
+ self . __refreshTail ( ) ;
1335
+ }
1336
+ setTimeout ( function ( ) {
1337
+ self . __refreshActive = false ;
1338
+ if ( self . __refreshDeactivate ) {
1339
+ self . __refreshDeactivate ( ) ;
1340
+ }
1328
1341
1329
- self . scrollTo ( self . __scrollLeft , self . __scrollTop , true ) ;
1330
-
1342
+ self . scrollTo ( self . __scrollLeft , self . __scrollTop , true ) ;
1343
+ } , self . __refreshTailTime ) ;
1344
+ } , delay ) ;
1331
1345
} ,
1332
1346
1333
1347
@@ -1939,10 +1953,14 @@ ionic.views.Scroll = ionic.views.View.inherit({
1939
1953
// We don't need to normalize scrollLeft, zoomLevel, etc. here because we only y-scrolling when pull-to-refresh is enabled
1940
1954
self . __publish ( self . __scrollLeft , - self . __refreshHeight , self . __zoomLevel , true ) ;
1941
1955
1956
+ var d = new Date ( ) ;
1957
+ self . refreshStartTime = d . getTime ( ) ;
1958
+
1942
1959
if ( self . __refreshStart ) {
1943
1960
self . __refreshStart ( ) ;
1944
1961
}
1945
-
1962
+ // for iOS-ey style scrolling
1963
+ if ( ! ionic . Platform . isAndroid ( ) ) self . __startDeceleration ( ) ;
1946
1964
} else {
1947
1965
1948
1966
if ( self . __interruptedAnimation || self . __isDragging ) {
@@ -2139,7 +2157,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
2139
2157
self . __minDecelerationScrollTop = 0 ;
2140
2158
self . __maxDecelerationScrollLeft = self . __maxScrollLeft ;
2141
2159
self . __maxDecelerationScrollTop = self . __maxScrollTop ;
2142
-
2160
+ if ( self . __refreshActive ) self . __minDecelerationScrollTop = self . __refreshHeight * - 1 ;
2143
2161
}
2144
2162
2145
2163
// Wrap class method
@@ -2160,11 +2178,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
2160
2178
2161
2179
//Make sure the scroll values are within the boundaries after a bounce,
2162
2180
//not below 0 or above maximum
2163
- if ( self . options . bouncing ) {
2181
+ if ( self . options . bouncing && ! self . __refreshActive ) {
2164
2182
self . scrollTo (
2165
2183
Math . min ( Math . max ( self . __scrollLeft , 0 ) , self . __maxScrollLeft ) ,
2166
2184
Math . min ( Math . max ( self . __scrollTop , 0 ) , self . __maxScrollTop ) ,
2167
- false
2185
+ self . __refreshActive
2168
2186
) ;
2169
2187
}
2170
2188
}
0 commit comments