|
1 | 1 | /**
|
2 |
| - * ng-FitText.js v4.1.0 |
| 2 | + * ng-FitText.js v4.1.1 |
3 | 3 | * https://github.com/patrickmarabeas/ng-FitText.js
|
4 | 4 | *
|
5 | 5 | * Original jQuery project: https://github.com/davatron5000/FitText.js
|
|
39 | 39 | angular.extend(config, fitTextConfig.config);
|
40 | 40 |
|
41 | 41 | var parent = element.parent()
|
| 42 | + , domElem = element[0] |
| 43 | + , domElemStyle = domElem.style |
42 | 44 | , computed = window.getComputedStyle(element[0], null)
|
43 | 45 | , newlines = element.children().length || 1
|
44 | 46 | , loadDelay = attrs.fittextLoadDelay || config.loadDelay
|
|
51 | 53 | ;
|
52 | 54 |
|
53 | 55 | function calculate() {
|
54 |
| - var ratio = (calcSize * newlines) / element[0].offsetWidth / newlines; |
| 56 | + var ratio = (calcSize * newlines) / domElem.offsetWidth / newlines; |
55 | 57 | return Math.max(
|
56 | 58 | Math.min((parent[0].offsetWidth - 6) * ratio * compressor,
|
57 | 59 | parseFloat(maxFontSize)
|
|
62 | 64 |
|
63 | 65 | function resizer() {
|
64 | 66 | // Don't calculate for elements with no width or height
|
65 |
| - if (element[0].offsetHeight * element[0].offsetWidth === 0) |
| 67 | + if (domElem.offsetHeight * domElem.offsetWidth === 0) |
66 | 68 | return;
|
67 | 69 |
|
68 | 70 | // Set standard values for calculation
|
69 |
| - element[0].style.fontSize = calcSize + 'px'; |
70 |
| - element[0].style.lineHeight = '1'; |
71 |
| - element[0].style.display = 'inline-block'; |
| 71 | + domElemStyle.fontSize = calcSize + 'px'; |
| 72 | + domElemStyle.lineHeight = '1'; |
| 73 | + domElemStyle.display = 'inline-block'; |
72 | 74 |
|
73 | 75 | // Set usage values
|
74 |
| - element[0].style.fontSize = calculate() + 'px'; |
75 |
| - element[0].style.lineHeight = lineHeight; |
76 |
| - element[0].style.display = display; |
| 76 | + domElemStyle.fontSize = calculate() + 'px'; |
| 77 | + domElemStyle.lineHeight = lineHeight; |
| 78 | + domElemStyle.display = display; |
77 | 79 | }
|
78 | 80 |
|
79 | 81 | $timeout( function() { resizer() }, loadDelay);
|
|
0 commit comments