1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Autofit textarea

This commit is contained in:
ksamuel
2020-08-12 14:14:13 +02:00
parent 7bf0ba4ddd
commit 6a0370b1f5
3 changed files with 14 additions and 2 deletions

View File

@ -844,3 +844,15 @@ if (app.support.history && zerobin.paste_not_found) {
}
})
}
/* Autofit text area height */
const tx = document.getElementsByTagName('textarea');
for (let i = 0; i < tx.length; i++) {
tx[i].setAttribute('style', 'height:' + (tx[i].scrollHeight) + 'px;overflow-y:hidden;');
tx[i].addEventListener("input", OnInput, false);
}
function OnInput() {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
}