From 2485b4a597a8f0f00ce623896ef8f8cf2a7bb843 Mon Sep 17 00:00:00 2001 From: Travis Russi Date: Sat, 30 Nov 2013 17:30:50 -0800 Subject: [PATCH] added watch to element height and extended timeout to 500ms --- js/ext/angular/src/directive/ionicContent.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index a93a4f2aca..3de74f1331 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -70,6 +70,20 @@ angular.module('ionic.ui.content', []) // Otherwise, supercharge this baby! // Add timeout to let content render so Scroller.resize grabs the right content height $timeout(function() { + + // Add watch to the container element's height to fire Scroller.resize event + $scope.$watch + ( + function () { + return typeof($element) !== "undefined" && $element.length > 0 && $element[0].clientHeight > 0 ? $element[0].clientHeight : 0; + }, + function (newValue, oldValue) { + if (newValue != oldValue && $scope.$parent && $scope.$parent.scrollView && $scope.$parent.scrollView.resize) { + $scope.$parent.scrollView.resize(); + } + } + ); + sv = new ionic.views.Scroller({ el: $element[0] }); @@ -87,7 +101,9 @@ angular.module('ionic.ui.content', []) */ // Let child scopes access this $scope.$parent.scrollView = sv; - }, 100); + }, 500); + + }