Skip to content

Commit

Permalink
fix: angle-slider max value (#2049)
Browse files Browse the repository at this point in the history
* fix: angle-slider max value

* chore: add clamps
  • Loading branch information
anubra266 authored Nov 27, 2024
1 parent 9fd7326 commit 3e7a576
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/clever-oranges-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/angle-slider": patch
---

Fix angle slider max value
4 changes: 3 additions & 1 deletion packages/machines/angle-slider/src/angle-slider.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { dom } from "./angle-slider.dom"
import type { MachineContext, MachineState, UserDefinedContext } from "./angle-slider.types"

const MIN_VALUE = 0
const MAX_VALUE = 360
const MAX_VALUE = 359

export function machine(userContext: UserDefinedContext) {
const ctx = compact(userContext)
Expand Down Expand Up @@ -176,6 +176,8 @@ const invoke = {
const set = {
value: (ctx: MachineContext, value: number) => {
if (ctx.value === value) return
if (value < MIN_VALUE || value > MAX_VALUE) return

ctx.value = value
invoke.valueChange(ctx)
},
Expand Down

0 comments on commit 3e7a576

Please sign in to comment.