type fixes

This commit is contained in:
MinamiFunakoshiTR 2025-05-22 11:59:36 -07:00
parent a44163ded4
commit b634c8bc4f
Failed to extract signature

View file

@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
let { value = $bindable(0), label = 'label' } = $props(); export let value = 0;
let isDragging = false; export let label = 'label';
function drag(node, callback) { function drag(node: HTMLElement) {
function handleMousedown(event) { function handleMousedown(event: MouseEvent) {
function handleMousemove(event) { function handleMousemove(event: MouseEvent) {
event.preventDefault(); event.preventDefault();
node.dispatchEvent( node.dispatchEvent(
@ -16,7 +16,7 @@
); );
} }
function handleMouseup(event) { function handleMouseup(event: MouseEvent) {
window.removeEventListener('mousemove', handleMousemove); window.removeEventListener('mousemove', handleMousemove);
window.removeEventListener('mouseup', handleMouseup); window.removeEventListener('mouseup', handleMouseup);
} }
@ -35,7 +35,7 @@
} }
// Round to 2 decimal places // Round to 2 decimal places
function round(value) { function round(value: number): number {
return Math.round(value * 100) / 100; return Math.round(value * 100) / 100;
} }
</script> </script>
@ -44,7 +44,15 @@
class="label" class="label"
style="top: {value * 100}%" style="top: {value * 100}%"
use:drag use:drag
on:drag={(e) => (value = e.detail.value)} ondrag={(event: DragEvent) => {
const customEvent = event as unknown as { detail: { value: number } };
value = customEvent.detail.value;
}}
role="slider"
aria-valuemin="0"
aria-valuemax="1"
aria-valuenow={value}
tabindex="0"
> >
<div class="drag-target"></div> <div class="drag-target"></div>
<hr /> <hr />