PageSourceSearch

https://www.albany.org/dist/TextVerticalStretch-BtfCveoR.js

js albany.org collected 2026-10-02 02:53:29 UTC 3,120 bytes, 1 lines download raw bytes

1const x=a=>{const e=typeof a=="number"&&Number.isFinite(a)?a:typeof a=="string"?Number.parseFloat(a):null;return e===null||!Number.isFinite(e)?null:Math.max(-.5,Math.min(e,1.5))},E=(a={})=>({span:null,textSpan:null,resizeTarget:null,resizeObserver:null,resizeHandler:null,canvasContext:null,lastFontSize:null,stretchFontSize:null,bleed:x(a.bleed)??0,hasSized:!1,init(){return()=>this.mounted()},mounted(){if(this.span=this.$el.querySelector(":scope > span"),this.textSpan=this.$el.querySelector(":scope > span > span"),!this.span)return;const e=this.$el.getAttribute("data-stretch-bleed"),h=e?x(e):null;h!==null&&(this.bleed=h),this.adjustFontSize(),window.setTimeout(()=>this.adjustFontSize(),150),"ResizeObserver"in window?(this.resizeTarget=this.$el.parentElement??this.$el,this.resizeObserver=new ResizeObserver(()=>{this.adjustFontSize()}),this.resizeTarget&&this.resizeObserver.observe(this.resizeTarget)):(this.resizeHandler=()=>this.adjustFontSize(),window.addEventListener("resize",this.resizeHandler))},adjustFontSize(){if(!this.span)return;const e=this.$el.getBoundingClientRect().height;if(!e)return;const{fontSize:h}=window.getComputedStyle(this.span),d=Number.parseFloat(h);if(!Number.isFinite(d))return;let u=Math.max(8,d*.4),z=Math.max(e,d*1.5),f=u;const m=()=>{const t=this.textSpan??this.span;if(!t)return{height:0,width:0};const o=t.textContent?.trim()??"",n=window.getComputedStyle(t);let r=0,i=0;if(o&&n.fontFamily&&n.fontSize){if(!this.canvasContext){const g=document.createElement("canvas");this.canvasContext=g.getContext("2d")}if(this.canvasContext){const{fontStyle:g,fontVariant:y,fontWeight:B,fontStretch:M,fontFamily:T}=n;this.canvasContext.font=`${g} ${y} ${B} ${M} ${n.fontSize} ${T}`;const s=this.canvasContext.measureText(o),v=s.actualBoundingBoxAscent??s.fontBoundingBoxAscent??s.emHeightAscent??0,$=s.actualBoundingBoxDescent??s.fontBoundingBoxDescent??s.emHeightDescent??0,N=s.actualBoundingBoxRight??0,H=s.actualBoundingBoxLeft??0;r=v+$,i=N+Math.abs(H),!i&&s.width&&(i=s.width)}}const c=t.ownerDocument.createRange();c.selectNodeContents(t);const S=c.getBoundingClientRect(),b=S.height||0,F=S.width||0,p=t.getBoundingClientRect(),w=p.height||0,C=p.width||0;return{height:Math.max(r,b,w),width:Math.max(i,F,C)}};for(let t=0;t<12;t+=1){const o=(u+z)/2;this.span.style.fontSize=`${o}px`;const{height:n}=m();if(!n)break;if(n>e)z=o;else{if(f=o,e-n<=1)break;u=o}}const l=f;if(this.lastFontSize===null||Math.abs(l-this.lastFontSize)>.1){this.span.style.fontSize=`${l}px`;let t=l;const{height:o,width:n}=m(),r=Math.max(o,n);if(r>0){const i=e/r;if(Number.isFinite(i)&&Math.abs(1-i)>.01){const c=Math.min(Math.max(i,.75),1.5);t=l*c,this.span.style.fontSize=`${t}px`}}if(this.bleed!==0){const i=1+this.bleed*(r/e);t=t*i,this.span.style.fontSize=`${t}px`}this.lastFontSize=t,this.stretchFontSize=t,this.hasSized||(this.hasSized=!0)}},destroy(){this.resizeObserver?.disconnect(),this.resizeObserver=null,this.resizeTarget=null,this.textSpan=null,this.canvasContext=null,this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null)}});export{E as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.