Skip to content

Commit d67a1c6

Browse files
authored
Merge pull request #71 from ventralnet/master
#70 Ability to specify a fall back font size before ellipsising takes place
2 parents 0aca49a + 93b3742 commit d67a1c6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ If a custom append string is included, a function can be executed on the resulti
5555
You can use string separator to split the string by something else than " " (space). Example (split by characters):
5656
``<p data-ng-bind="paragraphText" data-ellipsis data-separator=""></p>``
5757

58+
* **Fallback Font-Size**
59+
You can specify a fallback font size. If text is detected to overflow an attempt to resize the text to the fallback font-size will be made before ellipsis are added.
60+
``<p data-ng-bind="paragraphText" data-ellipsis data.ellipsis-falback-font-size="90%"></p>``
61+
5862
COMPATIBILITY
5963
--------
6064
Works on modern web browers, which includes any relatively recent version of Chrome, Firefox, Safari, and IE 9+. Although there is no formally-maintained list, mobile device support is quite thorough. I will update cross-browser and device issues if they are entered as issues.

src/angular-ellipsis.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ angular.module('dibari.angular-ellipsis', [])
6262
ellipsisSymbol: '@',
6363
ellipsisSeparator: '@',
6464
useParent: "@",
65-
ellipsisSeparatorReg: '='
65+
ellipsisSeparatorReg: '=',
66+
ellipsisFallbackFontSize:'@'
6667
},
6768
compile: function(elem, attr, linker) {
6869

@@ -75,6 +76,10 @@ angular.module('dibari.angular-ellipsis', [])
7576
/* State Variables */
7677
attributes.isTruncated = false;
7778

79+
function _isDefined(value) {
80+
return typeof(value) !== 'undefined';
81+
}
82+
7883
function getParentHeight(element) {
7984
var heightOfChildren = 0;
8085
angular.forEach(element.parent().children(), function(child) {
@@ -108,6 +113,10 @@ angular.module('dibari.angular-ellipsis', [])
108113
element.text(binding);
109114
}
110115

116+
if (_isDefined(attributes.ellipsisFallbackFontSize) && isOverflowed(element)) {
117+
element.css('font-size',attributes.ellipsisFallbackFontSize);
118+
}
119+
111120
// If text has overflow
112121
if (isOverflowed(element, scope.useParent)) {
113122
var bindArrayStartingLength = bindArray.length,

0 commit comments

Comments
 (0)