feat(ionContent): don't wrap in a .scroll element if scroll="false"

Fixes #841. Closes #897.
This commit is contained in:
Jay Proulx
2014-03-25 14:35:01 -04:00
committed by Andy Joslin
parent cf92d6c21c
commit 73da93d4a4
2 changed files with 43 additions and 11 deletions

View File

@@ -48,7 +48,7 @@ angular.module('ionic.ui.content', ['ionic.ui.scroll'])
* with {@link ionic.service:$ionicScrollDelegate}.
* @param {boolean=} padding Whether to add padding to the content.
* of the content. Defaults to true on iOS, false on Android.
* @param {boolean=} scroll Whether to allow scrolling of content. Defaults to true.
* @param {boolean=} scroll Whether to allow scrolling of content. Defaults to true. Note: scroll="false" removes the .scroll child element on element compilation, not on scope change
* @param {boolean=} overflow-scroll Whether to use overflow-scrolling instead of
* Ionic scroll.
* @param {boolean=} has-bouncing Whether to allow scrolling to bounce past the edges
@@ -66,12 +66,17 @@ function($timeout, $controller, $ionicBind) {
require: '^?ionNavView',
scope: true,
compile: function(element, attr) {
var innerElement;
element.addClass('scroll-content');
//We cannot transclude here because it breaks element.data() inheritance on compile
var innerElement = angular.element('<div class="scroll"></div>');
innerElement.append(element.contents());
element.append(innerElement);
if (attr.scroll != 'false') {
//We cannot use normal transclude here because it breaks element.data()
//inheritance on compile
innerElement = angular.element('<div class="scroll"></div>');
innerElement.append(element.contents());
element.append(innerElement);
}
return { pre: prelink };
function prelink($scope, $element, $attr, navViewCtrl) {
@@ -104,7 +109,7 @@ function($timeout, $controller, $ionicBind) {
if (angular.isDefined($attr.padding)) {
$scope.$watch($attr.padding, function(newVal) {
innerElement.toggleClass('padding', !!newVal);
(innerElement || $element).toggleClass('padding', !!newVal);
});
}