@@ -848,7 +848,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
848
848
849
849
self . hintResize ( ) ;
850
850
self . scrollBy (
851
- e . wheelDeltaX / self . options . wheelDampen ,
851
+ e . wheelDeltaX / self . options . wheelDampen ,
852
852
- e . wheelDeltaY / self . options . wheelDampen
853
853
) ;
854
854
@@ -1585,6 +1585,9 @@ ionic.views.Scroll = ionic.views.View.inherit({
1585
1585
self . __initialTouchLeft = currentTouchLeft ;
1586
1586
self . __initialTouchTop = currentTouchTop ;
1587
1587
1588
+ // Store initial touchList for scale calculation
1589
+ self . __initialTouches = touches ;
1590
+
1588
1591
// Store current zoom level
1589
1592
self . __zoomLevelStart = self . __zoomLevel ;
1590
1593
@@ -1644,6 +1647,11 @@ ionic.views.Scroll = ionic.views.View.inherit({
1644
1647
if ( touches . length === 2 ) {
1645
1648
currentTouchLeft = Math . abs ( touches [ 0 ] . pageX + touches [ 1 ] . pageX ) / 2 ;
1646
1649
currentTouchTop = Math . abs ( touches [ 0 ] . pageY + touches [ 1 ] . pageY ) / 2 ;
1650
+
1651
+ // Calculate scale when not present and only when touches are used
1652
+ if ( ! scale && self . options . zooming ) {
1653
+ scale = self . __getScale ( self . __initialTouches , touches ) ;
1654
+ }
1647
1655
} else {
1648
1656
currentTouchLeft = touches [ 0 ] . pageX ;
1649
1657
currentTouchTop = touches [ 0 ] . pageY ;
@@ -2255,6 +2263,39 @@ ionic.views.Scroll = ionic.views.View.inherit({
2255
2263
}
2256
2264
}
2257
2265
}
2266
+ } ,
2267
+
2268
+
2269
+ /**
2270
+ * calculate the distance between two touches
2271
+ * @param {Touch } touch1
2272
+ * @param {Touch } touch2
2273
+ * @returns {Number } distance
2274
+ */
2275
+ __getDistance : function getDistance ( touch1 , touch2 ) {
2276
+ var x = touch2 . pageX - touch1 . pageX ,
2277
+ y = touch2 . pageY - touch1 . pageY ;
2278
+ return Math . sqrt ( ( x * x ) + ( y * y ) ) ;
2279
+ } ,
2280
+
2281
+
2282
+ /**
2283
+ * calculate the scale factor between two touchLists (fingers)
2284
+ * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
2285
+ * @param {Array } start
2286
+ * @param {Array } end
2287
+ * @returns {Number } scale
2288
+ */
2289
+ __getScale : function getScale ( start , end ) {
2290
+
2291
+ var self = this ;
2292
+
2293
+ // need two fingers...
2294
+ if ( start . length >= 2 && end . length >= 2 ) {
2295
+ return self . __getDistance ( end [ 0 ] , end [ 1 ] ) /
2296
+ self . __getDistance ( start [ 0 ] , start [ 1 ] ) ;
2297
+ }
2298
+ return 1 ;
2258
2299
}
2259
2300
} ) ;
2260
2301
0 commit comments