added watch to element height and extended timeout to 500ms

This commit is contained in:
Travis Russi
2013-11-30 17:30:50 -08:00
parent 1fd7be8785
commit 2485b4a597

View File

@@ -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);
}