Skip to content

Instantly share code, notes, and snippets.

View navaru's full-sized avatar
🛰️
Refactoring the mothership

Navaru navaru

🛰️
Refactoring the mothership
View GitHub Profile
@navaru
navaru / gist:5779160
Last active February 7, 2019 16:46
Textarea auto-resize vanilla javascript (no jQuery plugin), for modern browsers
;(function () {
function domReady (f) { /in/.test(document.readyState) ? setTimeout(domReady,16,f) : f() }
function resize (event) {
event.target.style.height = 'auto';
event.target.style.height = event.target.scrollHeight+'px';
}
/* 0-timeout to get the already changed text */
function delayedResize (event) {
window.setTimeout(resize, 0, event);