diff --git a/js/angular/controller/scrollController.js b/js/angular/controller/scrollController.js index f04f5bb87b..af27550986 100644 --- a/js/angular/controller/scrollController.js +++ b/js/angular/controller/scrollController.js @@ -157,7 +157,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca if(curElm !== null)scrollTop += curElm.offsetTop; curElm = curElm.offsetParent; levelsClimbed++; - } while (curElm.attributes != self.element.attributes && curElm.offsetParent !== null); + } while (curElm.attributes != self.element.attributes && curElm.offsetParent); scrollView.scrollTo(scrollLeft, scrollTop, !!shouldAnimate); }); }; diff --git a/test/unit/angular/controller/scrollController.unit.js b/test/unit/angular/controller/scrollController.unit.js index ab677a8007..f4315dc37b 100644 --- a/test/unit/angular/controller/scrollController.unit.js +++ b/test/unit/angular/controller/scrollController.unit.js @@ -310,7 +310,7 @@ describe('$ionicScroll Controller', function() { }); }); - it('should work', function() { + it('.anchorScroll with el matching hash should scroll to it, even if the el is not directly below the list', function() { var ele = { offsetLeft: 8, offsetTop: 9,