Mercurial Hosting > chat
comparison src/chat.js @ 124:05489f6e9d6f default tip
faster fixTextarea
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 29 Jan 2026 09:07:08 -0700 |
| parents | 1ae3613dd090 |
| children |
comparison
equal
deleted
inserted
replaced
| 123:50f611bbfa19 | 124:05489f6e9d6f |
|---|---|
| 45 fixPosts(); | 45 fixPosts(); |
| 46 document.querySelector('div[input] textarea').focus(); | 46 document.querySelector('div[input] textarea').focus(); |
| 47 document.querySelector('div[input]').scrollIntoView({block: 'end'}); | 47 document.querySelector('div[input]').scrollIntoView({block: 'end'}); |
| 48 } | 48 } |
| 49 | 49 |
| 50 let textareaInitialHeight; | |
| 51 | |
| 50 function fixTextarea(event) { | 52 function fixTextarea(event) { |
| 51 let textarea = event.target; | 53 let textarea = event.target; |
| 52 textarea.style.height = 'initial'; | 54 if( !textareaInitialHeight ) |
| 55 textareaInitialHeight = getComputedStyle(textarea).height; | |
| 56 textarea.style.height = textareaInitialHeight; | |
| 53 textarea.style.height = (textarea.scrollHeight+2) + 'px'; | 57 textarea.style.height = (textarea.scrollHeight+2) + 'px'; |
| 54 textarea.scrollIntoViewIfNeeded(false); | 58 textarea.scrollIntoViewIfNeeded(false); |
| 55 } | 59 } |
| 56 | 60 |
| 57 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; | 61 const isMobile = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; |
