mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(ion-content): watch padding attribute
This commit is contained in:
6
js/ext/angular/src/directive/ionicContent.js
vendored
6
js/ext/angular/src/directive/ionicContent.js
vendored
@@ -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") {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user