mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
resize param input on value change
This commit is contained in:
parent
1c69333210
commit
130c8dee14
1 changed files with 16 additions and 1 deletions
|
|
@ -3,11 +3,25 @@ Copyright: Ankitects Pty Ltd and contributors
|
||||||
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { tick } from "svelte";
|
||||||
|
|
||||||
export let value: number[];
|
export let value: number[];
|
||||||
export let defaults: number[];
|
export let defaults: number[];
|
||||||
|
|
||||||
let stringValue: string;
|
let stringValue: string;
|
||||||
$: stringValue = render(value);
|
let taRef: HTMLTextAreaElement;
|
||||||
|
|
||||||
|
function updateHeight() {
|
||||||
|
if (taRef) {
|
||||||
|
taRef.style.height = "auto";
|
||||||
|
taRef.style.height = `${taRef.scrollHeight}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
stringValue = render(value);
|
||||||
|
tick().then(updateHeight);
|
||||||
|
}
|
||||||
|
|
||||||
function render(params: number[]): string {
|
function render(params: number[]): string {
|
||||||
return params.map((v) => v.toFixed(4)).join(", ");
|
return params.map((v) => v.toFixed(4)).join(", ");
|
||||||
|
|
@ -23,6 +37,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
|
bind:this={taRef}
|
||||||
value={stringValue}
|
value={stringValue}
|
||||||
on:blur={update}
|
on:blur={update}
|
||||||
class="w-100"
|
class="w-100"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue