blob: f690d4c0c32449ef3f4451b78e94f0bc05f7ffed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
// Credits to https://codepen.io/tomhodgins/pen/KgazaE
(function () {
const textareas = <NodeListOf<HTMLTextAreaElement>>document.querySelectorAll('textarea.frostAutoExpand');
const _frostAutoExpand = (el: HTMLElement) => {
el.style.height = 'inherit'
el.style.height = `${el.scrollHeight}px`
};
function _frostExpandAll() {
textareas.forEach(_frostAutoExpand);
}
textareas.forEach(el => {
const __frostAutoExpand = () => {
_frostAutoExpand(el)
};
el.addEventListener('paste', __frostAutoExpand)
el.addEventListener('input', __frostAutoExpand)
el.addEventListener('keyup', __frostAutoExpand)
});
window.addEventListener('load', _frostExpandAll)
window.addEventListener('resize', _frostExpandAll)
}).call(undefined);
|