better gui
This commit is contained in:
18
frontend/src/lib/common/autogrow.js
Normal file
18
frontend/src/lib/common/autogrow.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { tick } from "svelte";
|
||||
|
||||
export function autoGrow(node) {
|
||||
function resize() {
|
||||
node.style.height = "auto";
|
||||
node.style.height = node.scrollHeight + "px";
|
||||
}
|
||||
|
||||
// wait until DOM updates to apply initial value
|
||||
tick().then(resize);
|
||||
node.addEventListener("input", resize);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
node.removeEventListener("input", resize);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user