Skip to content

Commit e7016f5

Browse files
committedOct 22, 2024··
fix: snapping on load
fixed knob snapping from 50% to 0% on mount
1 parent 03d5adc commit e7016f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "svelte-knobs",
33
"description": "Svelte component library for building customizable knob controls.",
4-
"version": "0.0.2",
4+
"version": "0.0.3",
55
"repository": {
66
"url": "https://github.com/eye-wave/svelte-knobs"
77
},

‎src/lib/Knob.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
$: circleRadius = size * 0.32;
2626
$: lineWidth = size * 0.04;
2727
28-
$: rotationDegrees = spring(0, { stiffness });
29-
3028
let isDragging = false;
3129
let startY: number;
3230
let startValue: number;
@@ -50,6 +48,9 @@
5048
5149
$: fixedSnapValues = completeFixedSnapValues(snapValues);
5250
51+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
52+
const rotationDegrees = spring(normalize(value as any, param as any) * 270 - 135, { stiffness });
53+
5354
// eslint-disable-next-line @typescript-eslint/no-explicit-any
5455
$: normalizedValue = normalize(value as any, param as any);
5556
$: rotationDegrees.set(normalizedValue * 270 - 135);

0 commit comments

Comments
 (0)
Please sign in to comment.