feat(ion-content): watch padding attribute

This commit is contained in:
Andy Joslin
2014-03-18 15:03:42 -06:00
parent ae57b2b81a
commit 532d473e35
2 changed files with 7 additions and 7 deletions

View File

@@ -42,7 +42,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service', 'ionic.ui.scroll'])
* directive, and infinite scrolling with the {@link ionic.directive:ionInfiniteScroll}
* directive.
*
* Use the classes 'has-header', 'has-subheader', 'has-footer', and 'has-tabs'
* Use the classes 'has-header', 'has-subheader', 'has-footer', and 'has-tabs'
* to modify the positioning of the ion-content relative to surrounding elements.
*
* @param {boolean=} padding Whether to add padding to the content.
@@ -72,8 +72,6 @@ function($parse, $timeout, $controller, $ionicBind) {
'<div class="scroll"></div>' +
'</div>',
compile: function(element, attr, transclude) {
if(attr.padding == "true") { element.find('div').addClass('padding'); }
return {
//Prelink <ion-content> so it can compile before other directives compile.
//Then other directives can require ionicScrollCtrl
@@ -100,7 +98,7 @@ function($parse, $timeout, $controller, $ionicBind) {
});
$scope.$watch($attr.padding, function(newVal) {
$element.toggleClass('padding', !!newVal);
scrollContent.toggleClass('padding', !!newVal);
});
if ($scope.scroll === "false") {

View File

@@ -22,11 +22,13 @@ describe('Ionic Content directive', function() {
});
it('should add padding classname', function() {
var element = compile('<ion-content padding="true"></ion-content>')(scope);
expect(element.hasClass('scroll-content')).toEqual(true);
expect(element.hasClass('padding')).toEqual(false);
var element = compile('<ion-content padding="shouldPad"></ion-content>')(scope);
var scrollElement = element.find('.scroll');
expect(scrollElement.hasClass('padding')).toEqual(false);
element.scope().$apply('shouldPad = true');
expect(scrollElement.hasClass('padding')).toEqual(true);
element.scope().$apply('shouldPad = false');
expect(scrollElement.hasClass('padding')).toEqual(false);
});
it('Disables bouncing when has-bouncing = false', function() {