mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Resize fsrs params input to fit content (#3999)
* resize param input on value change * resize on window resize
This commit is contained in:
parent
8f2c708751
commit
97b12b420a
1 changed files with 18 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
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { tick } from "svelte";
|
||||
|
||||
export let value: number[];
|
||||
export let defaults: number[];
|
||||
|
||||
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 {
|
||||
return params.map((v) => v.toFixed(4)).join(", ");
|
||||
|
@ -22,7 +36,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onresize={updateHeight} />
|
||||
|
||||
<textarea
|
||||
bind:this={taRef}
|
||||
value={stringValue}
|
||||
on:blur={update}
|
||||
class="w-100"
|
||||
|
|
Loading…
Reference in a new issue