Hi,
I’m wondering if anyone could help me. I have NavBar titles that can be quite long and are often cut short by Ionic. Therefore my idea was to have a scrolling title to do this I added the following code.
HTML
<ion-view>
<ion-nav-title><div ui-text-scroll>{{name}}</div></ion-nav-title>
...
</ion-view>
CSS
@-webkit-keyframes textScroll {
0% {
-webkit-transform: translate(0,0);
}
100% {
-webkit-transform: translate(-100%,0);
}
}
.scrollText {
display:inline-block;
padding-left: 100%;
-webkit-animation: textScroll 10s infinite linear;
}
Directive
.directive('uiTextScroll',function() {
return {
restrict: 'AC',
link: function(scope, element){
if(isOverflowed(element)) {
element.addClass('scrollText');
}
function isOverflowed(thisElement) {
//Unknown
return true;
}
}
};
})
By setting the isOverFlowed to true the text will scroll but I am looking to only add the scrolling class if the text is larger than the containing element.
So my problem is how do I find out if the text in the title is overflowing or not. I have tried comparing the scrollWidth to the clientWidth but both are blank. Can anyone please help me to fill in the blank here?
Thanks
H