openstack-uicore-foundation
Version:
ui reactjs components for openstack marketing site
2 lines • 1.43 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={};(()=>{e.d=(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})}})(),(()=>{e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var t={};e.r(t),e.d(t,{default:()=>n});const o=require("react"),n=(e=50,t=130)=>{const n=t,r=e,i=(0,o.useRef)(null),[f,u]=(0,o.useState)({fontSize:r,fontSizePrev:n,fontSizeMax:r,fontSizeMin:n}),{fontSize:a,fontSizeMax:c,fontSizeMin:s,fontSizePrev:S}=f;return(0,o.useEffect)((()=>{const e=Math.abs(a-S)<=5,t=!!i.current&&(i.current.scrollHeight>i.current.offsetHeight||i.current.scrollWidth>i.current.offsetWidth),o=a>S;if(e){if(t){u({fontSize:S<a?S:a-(S-a),fontSizeMax:c,fontSizeMin:s,fontSizePrev:S})}return}let n,r=c,f=s;t?(n=o?S-a:s-a,r=Math.min(c,a)):(n=o?c-a:S-a,f=Math.max(s,a)),u({fontSize:a+n/2,fontSizeMax:r,fontSizeMin:f,fontSizePrev:a})}),[a,c,s,S,i]),{fontSize:`${a}%`,lineHeight:a-10+"%",ref:i}};return t})()));
//# sourceMappingURL=use-fit-text.js.map