Skip to content

Commit

Permalink
fix: snapping on load
Browse files Browse the repository at this point in the history
fixed knob snapping from 50% to 0% on mount
  • Loading branch information
eye-wave committed Oct 22, 2024
1 parent 03d5adc commit e7016f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "svelte-knobs",
"description": "Svelte component library for building customizable knob controls.",
"version": "0.0.2",
"version": "0.0.3",
"repository": {
"url": "https://github.com/eye-wave/svelte-knobs"
},
Expand Down
5 changes: 3 additions & 2 deletions src/lib/Knob.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
$: circleRadius = size * 0.32;
$: lineWidth = size * 0.04;
$: rotationDegrees = spring(0, { stiffness });
let isDragging = false;
let startY: number;
let startValue: number;
Expand All @@ -50,6 +48,9 @@
$: fixedSnapValues = completeFixedSnapValues(snapValues);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const rotationDegrees = spring(normalize(value as any, param as any) * 270 - 135, { stiffness });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
$: normalizedValue = normalize(value as any, param as any);
$: rotationDegrees.set(normalizedValue * 270 - 135);
Expand Down

0 comments on commit e7016f5

Please sign in to comment.