diff --git a/js/ext/angular/src/service/delegates/ionicScrollDelegate.js b/js/ext/angular/src/service/delegates/ionicScrollDelegate.js index 9b2ea289583..e3d6b4232d1 100644 --- a/js/ext/angular/src/service/delegates/ionicScrollDelegate.js +++ b/js/ext/angular/src/service/delegates/ionicScrollDelegate.js @@ -23,15 +23,24 @@ angular.module('ionic.ui.service.scrollDelegate', []) anchorScroll: function(animate) { $rootScope.$broadcast('scroll.anchorScroll', animate); }, - tapScrollToTop: function(element) { + tapScrollToTop: function(element, animate) { var _this = this; + if (!angular.isDefined(animate)) { + animate = true; + } ionic.on('tap', function(e) { + var target = e.target; + //Don't scroll to top for a button click + if (ionic.DomUtil.getParentOrSelfWithClass(target, 'button')) { + return; + } + var el = element[0]; var bounds = el.getBoundingClientRect(); if(ionic.DomUtil.rectContains(e.gesture.touches[0].pageX, e.gesture.touches[0].pageY, bounds.left, bounds.top, bounds.left + bounds.width, bounds.top + 20)) { - _this.scrollTop(); + _this.scrollTop(animate); } }, element[0]); }, diff --git a/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js b/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js index 3bf027b0675..33fc4831a39 100644 --- a/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js +++ b/js/ext/angular/test/service/delegates/ionicScrollDelegate.unit.js @@ -35,6 +35,38 @@ describe('Ionic ScrollDelegate Service', function() { testWithAnimate(false); function testWithAnimate(animate) { describe('with animate='+animate, function() { + + it('should tapScrollToTop', function() { + var scope = rootScope.$new(); + var el = angular.element('