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 December 18, 2024 14:29
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);