From 4e2a6c00371cef287cf23ae412ba0175bf1a2d0a Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Tue, 29 Apr 2014 17:11:07 -0500 Subject: [PATCH] feat(scrollView) - pinch to zoom. Fixes #679 --- js/angular/directive/scroll.js | 8 +++++++- js/views/scrollView.js | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/angular/directive/scroll.js b/js/angular/directive/scroll.js index 9ad0ce4728..d41a38c99e 100644 --- a/js/angular/directive/scroll.js +++ b/js/angular/directive/scroll.js @@ -46,6 +46,9 @@ function($timeout, $controller, $ionicBind) { scroll: '@', scrollbarX: '@', scrollbarY: '@', + zooming: '@', + minZoom: '@', + maxZoom: '@' }); if (angular.isDefined($attr.padding)) { @@ -67,7 +70,10 @@ function($timeout, $controller, $ionicBind) { scrollbarX: $scope.$eval($scope.scrollbarX) !== false, scrollbarY: $scope.$eval($scope.scrollbarY) !== false, scrollingX: $scope.direction.indexOf('x') >= 0, - scrollingY: $scope.direction.indexOf('y') >= 0 + scrollingY: $scope.direction.indexOf('y') >= 0, + zooming: $scope.$eval($scope.zooming) === true, + maxZoom: $scope.$eval($scope.maxZoom) || 3, + minZoom: $scope.$eval($scope.minZoom) || 0.5 }; if (isPaging) { scrollViewOptions.speedMultiplier = 0.8; diff --git a/js/views/scrollView.js b/js/views/scrollView.js index fb76860e8a..3abf07211b 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -725,7 +725,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ } } - self.doTouchMove(e.touches, e.timeStamp); + self.doTouchMove(e.touches, e.timeStamp, e.scale); }; self.touchEnd = function(e) { @@ -1062,7 +1062,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ if (helperElem.style[perspectiveProperty] !== undef) { return function(left, top, zoom, wasResize) { - content.style[transformProperty] = 'translate3d(' + (-left) + 'px,' + (-top) + 'px,0)'; + content.style[transformProperty] = 'translate3d(' + (-left) + 'px,' + (-top) + 'px,0) scale(' + zoom + ')'; self.__repositionScrollbars(); if(!wasResize) { self.triggerScrollEvent(); @@ -1072,7 +1072,7 @@ ionic.views.Scroll = ionic.views.View.inherit({ } else if (helperElem.style[transformProperty] !== undef) { return function(left, top, zoom, wasResize) { - content.style[transformProperty] = 'translate(' + (-left) + 'px,' + (-top) + 'px)'; + content.style[transformProperty] = 'translate(' + (-left) + 'px,' + (-top) + 'px) scale(' + zoom + ')'; self.__repositionScrollbars(); if(!wasResize) { self.triggerScrollEvent();