Merge pull request #241 from travisrussi/228-scroll

Scrolling on iPhone5 running iOS7 seems to be working
This commit is contained in:
Max Lynch
2013-12-02 06:41:48 -08:00
2 changed files with 46 additions and 20 deletions

View File

@@ -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,28 +62,49 @@ 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;
// Pass the parent scope down to the child
clone = transclude($scope.$parent);
angular.element($element[0].firstElementChild).append(clone);
// 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]
});
/*
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;
}, 500);
}
// if padding attribute is true, then add padding if it wasn't added to the .scroll

View File

@@ -582,7 +582,12 @@ 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(
Math.min(this.__container.clientWidth, this.__container.parentElement.clientWidth),
Math.min(this.__container.clientHeight, this.__container.parentElement.clientHeight),
this.__content.offsetWidth,
this.__content.offsetHeight+50);
},
/*
---------------------------------------------------------------------------