Skip to content

Commit cdba48f

Browse files
committed
fix(navBar): only add default animation if there is no custom animation
Closes #1671
1 parent 22a81fe commit cdba48f

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

Diff for: js/angular/directive/navBar.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ IonicModule.constant('$ionicNavBarConfig', {
2121
* We can add buttons depending on the currently visible view using
2222
* {@link ionic.directive:ionNavButtons}.
2323
*
24-
* Assign an [animation class](/docs/components#animations) to the element to
25-
* enable animated changing of titles (recommended: 'nav-title-slide-ios7')
24+
* Add an [animation class](/docs/components#animations) to the element via the
25+
* `animation` attribute to enable animated changing of titles
26+
* (recommended: 'nav-title-slide-ios7').
2627
*
2728
* Note that the ion-nav-bar element will only work correctly if your content has an
2829
* ionView around it.
@@ -32,7 +33,7 @@ IonicModule.constant('$ionicNavBarConfig', {
3233
* ```html
3334
* <body ng-app="starter">
3435
* <!-- The nav bar that will be updated as we navigate -->
35-
* <ion-nav-bar class="bar-positive nav-title-slide-ios7">
36+
* <ion-nav-bar class="bar-positive" animation="nav-title-slide-ios7">
3637
* </ion-nav-bar>
3738
*
3839
* <!-- where the initial view template will be rendered -->
@@ -94,7 +95,7 @@ function($ionicViewService, $rootScope, $animate, $compile, $ionicNavBarConfig)
9495
compile: function(tElement, tAttrs) {
9596
//We cannot transclude here because it breaks element.data() inheritance on compile
9697
tElement
97-
.addClass('bar bar-header nav-bar ' + $ionicNavBarConfig.transition)
98+
.addClass('bar bar-header nav-bar')
9899
.append(
99100
'<div class="buttons left-buttons"> ' +
100101
'</div>' +
@@ -103,6 +104,12 @@ function($ionicViewService, $rootScope, $animate, $compile, $ionicNavBarConfig)
103104
'</div>'
104105
);
105106

107+
if (isDefined(tAttrs.animation)) {
108+
tElement.addClass(tAttrs.animation);
109+
} else {
110+
tElement.addClass($ionicNavBarConfig.transition);
111+
}
112+
106113
return { pre: prelink };
107114
function prelink($scope, $element, $attr, navBarCtrl) {
108115
navBarCtrl._headerBarView = new ionic.views.HeaderBar({

Diff for: test/unit/angular/directive/navBar.unit.js

+12
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ describe('ionNavBar', function() {
323323
var el = setup();
324324
expect(el.hasClass('nav-title-slide-ios7')).toBe(true);
325325
});
326+
327+
it('should not add transition if animation attribute is defined', function() {
328+
var el = setup('animation="123abc"');
329+
expect(el.hasClass('123abc')).toBe(true);
330+
expect(el.hasClass('nav-title-slide-ios7')).toBe(false);
331+
});
326332
});
327333

328334
describe('Android', function() {
@@ -346,6 +352,12 @@ describe('ionNavBar', function() {
346352
// Nav bar titles don't animation by default on Android
347353
expect(el.hasClass('no-animation')).toBe(true);
348354
});
355+
356+
it('should not add transition if animation attribute is defined', function() {
357+
var el = setup('animation="123abc"');
358+
expect(el.hasClass('123abc')).toBe(true);
359+
expect(el.hasClass('no-animation')).toBe(false);
360+
});
349361
});
350362
});
351363
});

0 commit comments

Comments
 (0)