-
Notifications
You must be signed in to change notification settings - Fork 3
/
angular-textfill.js
36 lines (33 loc) · 1.13 KB
/
angular-textfill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict'
angular.module('ngTextFill', [])
.directive('textfill', ['$timeout', function ($timeout) {
return {
restrict: 'A',
scope: {
textfill: '@',
textfillOnSuccess: '=',
textfillOnFail: '=',
textfillOnComplete: '='
},
template: '<span>{{textfill}}</span>',
link: function (scope, element, attr) {
var container = element,
options = {
innerTag: attr.innerTag || "span",
debug: attr.debug || false,
minFontPixels: parseInt(attr.minFontPixels) || 4,
maxFontPixels: parseInt(attr.maxFontPixels) || 40,
widthOnly: attr.widthOnly || false,
explicitHeight: attr.explicitHeight || null,
explicitWidth: attr.explicitWidth || null,
success: scope.textfillOnSuccess || null,
fail: scope.textfillOnFail || null,
complete: scope.textfillOnComplete || null
};
container.textfill(options);
scope.$watch('textfill', function () {
container.textfill(options);
});
}
};
}]);