Skip to content

Commit 677d2d4

Browse files
committed
fix(header): ion-nav-title will fill up available space
ion-nav-title will fill up available space #4661
1 parent 44d5a0f commit 677d2d4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Diff for: js/angular/controller/headerBarController.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,20 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
104104

105105

106106
self.titleTextWidth = function() {
107-
if (!titleTextWidth) {
108-
var bounds = ionic.DomUtil.getTextBounds(getEle(TITLE));
109-
titleTextWidth = Math.min(bounds && bounds.width || 30);
107+
var element = getEle(TITLE);
108+
if ( element ) {
109+
// If the element has a nav-bar-title, use that instead
110+
// to calculate the width of the title
111+
var children = angular.element(element).children();
112+
for ( var i = 0; i < children.length; i++ ) {
113+
if ( angular.element(children[i]).hasClass('nav-bar-title') ) {
114+
element = children[i];
115+
break;
116+
}
117+
}
110118
}
119+
var bounds = ionic.DomUtil.getTextBounds(element);
120+
titleTextWidth = Math.min(bounds && bounds.width || 30);
111121
return titleTextWidth;
112122
};
113123

0 commit comments

Comments
 (0)