forked from patrickmarabeas/ng-FitText.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng-FitText.min.js
1 lines (1 loc) · 1.49 KB
/
ng-FitText.min.js
1
!function(t,e,i,n){"use strict";i.module("ngFitText",[]).value("fitTextDefaultConfig",{debounce:!1,delay:250,loadDelay:10,compressor:1,min:0,max:Number.POSITIVE_INFINITY}).directive("fittext",["$timeout","fitTextDefaultConfig","fitTextConfig",function(e,n,o){return{restrict:"A",scope:!0,link:function(f,a,l){function r(){var t=I*x/p.offsetWidth/x;return Math.max(Math.min((d[0].offsetWidth-(parseFloat(getComputedStyle(d[0]).paddingLeft)+parseFloat(getComputedStyle(d[0]).paddingRight))-6)*t*y,parseFloat(T)),parseFloat(C))}function u(){p.offsetHeight*p.offsetWidth!==0&&(g.fontSize=I+"px",g.lineHeight="1",g.display="inline-block",g.fontSize=r()+"px",g.lineHeight=z,g.display=F)}function c(){s&&e.cancel(s),s=e(function(){s=null,u()},5)}i.extend(n,o.config);var s,d=a.parent(),p=a[0],g=p.style,h=t.getComputedStyle(a[0],null),x=a.children().length||1,m=l.fittextLoadDelay||n.loadDelay,y=isNaN(parseInt(l.fittext))?n.compressor:l.fittext,v=l.fittextMin||n.min,b=l.fittextMax||n.max,C="inherit"===v?h["font-size"]:v,T="inherit"===b?h["font-size"]:b,z=h["line-height"],F=h.display,I=10;e(function(){c()},m),f.$watch(function(){return[f.$eval(l.ngBind),d[0].offsetWidth,a[0].offsetWidth].join("_")},function(){c()}),n.debounce?i.element(t).bind("resize",n.debounce(function(){f.$applyAsync(c)},n.delay)):i.element(t).bind("resize",function(){f.$applyAsync(c)})}}}]).provider("fitTextConfig",function(){var t=this;return this.config={},this.$get=function(){var e={};return e.config=t.config,e},this})}(window,document,angular);