fix: some test

This commit is contained in:
max_richter 2024-04-18 18:44:34 +02:00
parent 36faeae886
commit a15a54c61e
2 changed files with 29 additions and 20 deletions

View File

@ -1,6 +1,11 @@
<script lang="ts"> <script lang="ts">
import { decodeFloat, encodeFloat } from "$lib/helpers/encode"; import {
import { decode, encode, concat_encoded } from "$lib/helpers/flat_tree"; decodeFloat,
encodeFloat,
decode,
encode,
concat_encoded,
} from "@nodes/utils";
console.clear(); console.clear();

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher } from 'svelte'; import { createEventDispatcher } from "svelte";
import { getBoundingValue } from '../helpers/getBoundingValue'; import { getBoundingValue } from "../helpers/getBoundingValue";
export let value = 0.5; export let value = 0.5;
export let step = 0.01; export let step = 0.01;
@ -9,7 +9,7 @@
export let id = ""; export let id = "";
function strip(input: number) { function strip(input: number) {
return +parseFloat(input + '').toPrecision(2); return +parseFloat(input + "").toPrecision(2);
} }
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
@ -24,12 +24,12 @@
function handleChange() { function handleChange() {
if (value === oldValue) return; if (value === oldValue) return;
oldValue = value; oldValue = value;
dispatch('change', parseFloat(value + '')); dispatch("change", parseFloat(value + ""));
} }
$: width = Number.isFinite(value) $: width = Number.isFinite(value)
? Math.max((value?.toString().length ?? 1) * 8, 50) + 'px' ? Math.max((value?.toString().length ?? 1) * 8, 50) + "px"
: '20px'; : "20px";
let isMouseDown = false; let isMouseDown = false;
/* let downX = 0; */ /* let downX = 0; */
@ -49,10 +49,10 @@
/* downY = ev.clientY; */ /* downY = ev.clientY; */
rect = inputEl.getBoundingClientRect(); rect = inputEl.getBoundingClientRect();
window.removeEventListener('mousemove', handleMouseMove); window.removeEventListener("mousemove", handleMouseMove);
window.addEventListener('mousemove', handleMouseMove); window.addEventListener("mousemove", handleMouseMove);
window.addEventListener('mouseup', handleMouseUp); window.addEventListener("mouseup", handleMouseUp);
document.body.style.cursor = 'ew-resize'; document.body.style.cursor = "ew-resize";
} }
function handleMouseUp() { function handleMouseUp() {
@ -72,13 +72,13 @@
} }
}, 500); }, 500);
document.body.style.cursor = 'unset'; document.body.style.cursor = "unset";
window.removeEventListener('mouseup', handleMouseUp); window.removeEventListener("mouseup", handleMouseUp);
window.removeEventListener('mousemove', handleMouseMove); window.removeEventListener("mousemove", handleMouseMove);
} }
function handleKeyDown(ev: KeyboardEvent) { function handleKeyDown(ev: KeyboardEvent) {
if (ev.key === 'Escape' || ev.key === 'Enter') { if (ev.key === "Escape" || ev.key === "Enter") {
handleMouseUp(); handleMouseUp();
inputEl.blur(); inputEl.blur();
} }
@ -98,10 +98,14 @@
</script> </script>
<div class="component-wrapper" class:is-down={isMouseDown}> <div class="component-wrapper" class:is-down={isMouseDown}>
<span class="overlay" style={`width: ${((value - min) / (max - min)) * 100}%`} /> <span
class="overlay"
style={`width: ${((value - min) / (max - min)) * 100}%`}
/>
<input <input
bind:value bind:value
bind:this={inputEl} bind:this={inputEl}
{id}
{step} {step}
{max} {max}
{min} {min}
@ -126,12 +130,12 @@
border-radius: var(--border-radius, 2px); border-radius: var(--border-radius, 2px);
} }
input[type='number']::-webkit-inner-spin-button, input[type="number"]::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button { input[type="number"]::-webkit-outer-spin-button {
-webkit-appearance: none; -webkit-appearance: none;
} }
input[type='number'] { input[type="number"] {
box-sizing: border-box; box-sizing: border-box;
-webkit-appearance: textfield; -webkit-appearance: textfield;
-moz-appearance: textfield; -moz-appearance: textfield;