From efa61844860349fb3045cb3b9cd962fba615ae8c Mon Sep 17 00:00:00 2001 From: Andrew Joslin Date: Wed, 14 May 2014 10:14:02 -0600 Subject: [PATCH] fix(ion-header-bar): when hidden, correctly offset the ion-content Fixes #1351 --- js/angular/directive/headerFooterBar.js | 10 ++++++---- .../angular/directive/headerFooterBar.unit.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/js/angular/directive/headerFooterBar.js b/js/angular/directive/headerFooterBar.js index a7bcef47227..14472684365 100644 --- a/js/angular/directive/headerFooterBar.js +++ b/js/angular/directive/headerFooterBar.js @@ -125,9 +125,10 @@ function headerFooterBarDirective(isHeader) { if (isHeader) { $scope.$watch(function() { return el.className; }, function(value) { + var isShown = value.indexOf('ng-hide') === -1; var isSubheader = value.indexOf('bar-subheader') !== -1; - $scope.$hasHeader = !isSubheader; - $scope.$hasSubheader = isSubheader; + $scope.$hasHeader = isShown && !isSubheader; + $scope.$hasSubheader = isShown && isSubheader; }); $scope.$on('$destroy', function() { delete $scope.$hasHeader; @@ -135,9 +136,10 @@ function headerFooterBarDirective(isHeader) { }); } else { $scope.$watch(function() { return el.className; }, function(value) { + var isShown = value.indexOf('ng-hide') === -1; var isSubfooter = value.indexOf('bar-subfooter') !== -1; - $scope.$hasFooter = !isSubfooter; - $scope.$hasSubfooter = isSubfooter; + $scope.$hasFooter = isShown && !isSubfooter; + $scope.$hasSubfooter = isShown && isSubfooter; }); $scope.$on('$destroy', function() { delete $scope.$hasFooter; diff --git a/test/unit/angular/directive/headerFooterBar.unit.js b/test/unit/angular/directive/headerFooterBar.unit.js index 7d32a7eadc4..a5ce05a0c20 100644 --- a/test/unit/angular/directive/headerFooterBar.unit.js +++ b/test/unit/angular/directive/headerFooterBar.unit.js @@ -109,6 +109,14 @@ describe('bar directives', function() { scope.$apply(); expect(scope.$hasHeader).toEqual(true); expect(scope.$hasSubheader).toEqual(false); + el.addClass('ng-hide'); + scope.$apply(); + expect(scope.$hasHeader).toEqual(false); + expect(scope.$hasSubheader).toEqual(false); + el.removeClass('ng-hide'); + scope.$apply(); + expect(scope.$hasHeader).toEqual(true); + expect(scope.$hasSubheader).toEqual(false); }); } else { it('$hasFooter $hasSubheader', function() { @@ -124,6 +132,14 @@ describe('bar directives', function() { scope.$apply(); expect(scope.$hasFooter).toEqual(true); expect(scope.$hasSubfooter).toEqual(false); + el.addClass('ng-hide'); + scope.$apply(); + expect(scope.$hasFooter).toEqual(false); + expect(scope.$hasSubfooter).toEqual(false); + el.removeClass('ng-hide'); + scope.$apply(); + expect(scope.$hasFooter).toEqual(true); + expect(scope.$hasSubfooter).toEqual(false); }); it('.has-tabs', function() { var el = setup();