You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/javascript/elements/autosize_field.js

22 lines
674 B

export default class extends HTMLElement {
connectedCallback () {
const originalFontValue = this.field.style.fontSize
if (this.field.scrollHeight > this.field.clientHeight) {
this.field.style.fontSize = `calc(${originalFontValue} / 1.5)`
this.field.style.lineHeight = `calc(${this.field.style.fontSize} * 1.3)`
if (this.field.scrollHeight > this.field.clientHeight) {
this.field.style.fontSize = `calc(${originalFontValue} / 2.0)`
this.field.style.lineHeight = `calc(${this.field.style.fontSize} * 1.3)`
}
}
this.field.classList.remove('hidden')
}
get field () {
return this.closest('field-value')
}
}