From c96a46a0d7bcff860c36a073c0926ff4cc77f518 Mon Sep 17 00:00:00 2001 From: Travis Russi Date: Sat, 30 Nov 2013 16:24:20 -0800 Subject: [PATCH] fixed resize issue for scrolling --- js/ext/angular/src/directive/ionicContent.js | 40 +++++++++++--------- js/views/scrollZyng.js | 3 +- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index fb0db2b440..384c4d8880 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -18,7 +18,7 @@ angular.module('ionic.ui.content', []) // The content directive is a core scrollable content area // that is part of many View hierarchies -.directive('content', ['$parse', function($parse) { +.directive('content', ['$parse', '$timeout', function($parse, $timeout) { return { restrict: 'E', replace: true, @@ -62,24 +62,28 @@ angular.module('ionic.ui.content', []) addedPadding = true; } $element.append(sc); + // Otherwise, supercharge this baby! - sv = new ionic.views.Scroller({ - el: $element[0] - }); - /* - hasPullToRefresh: (typeof $scope.onRefresh !== 'undefined'), - onRefresh: function() { - $scope.onRefresh(); - $scope.$parent.$broadcast('scroll.onRefresh'); - }, - onRefreshOpening: function(amt) { - $scope.onRefreshOpening({amount: amt}); - $scope.$parent.$broadcast('scroll.onRefreshOpening', amt); - } - }); - */ - // Let child scopes access this - $scope.$parent.scrollView = sv; + // Add timeout to let content render so Scroller.resize grabs the right content height + $timeout(function() { + sv = new ionic.views.Scroller({ + el: $element[0] + }); + /* + hasPullToRefresh: (typeof $scope.onRefresh !== 'undefined'), + onRefresh: function() { + $scope.onRefresh(); + $scope.$parent.$broadcast('scroll.onRefresh'); + }, + onRefreshOpening: function(amt) { + $scope.onRefreshOpening({amount: amt}); + $scope.$parent.$broadcast('scroll.onRefreshOpening', amt); + } + }); + */ + // Let child scopes access this + $scope.$parent.scrollView = sv; + }, 100); // Pass the parent scope down to the child clone = transclude($scope.$parent); diff --git a/js/views/scrollZyng.js b/js/views/scrollZyng.js index e9567c59ea..ecaaaf5c6f 100644 --- a/js/views/scrollZyng.js +++ b/js/views/scrollZyng.js @@ -582,7 +582,8 @@ var Scroller; resize: function() { // Update Scroller dimensions for changed content - this.setDimensions(this.__container.clientWidth, this.__container.clientHeight, this.__content.offsetWidth, this.__content.offsetHeight-50); + // Add padding to bottom of content + this.setDimensions(this.__container.clientWidth, this.__container.clientHeight, this.__content.offsetWidth, this.__content.offsetHeight+50); }, /* ---------------------------------------------------------------------------