mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-07 00:46:44 -03:00
fix(slider): fix floating point precision issues in SingleSlider and DualRangeSlider
JavaScript floating point arithmetic causes values like 1.1 to become 1.1000000000000014. Add precision limiting to 2 decimal places in snapToStep function for both sliders.
This commit is contained in:
@@ -82,7 +82,9 @@ const stepToDecimals = (step: number): number => {
|
||||
|
||||
const snapToStep = (value: number): number => {
|
||||
const steps = Math.round((value - props.min) / props.step)
|
||||
return Math.max(props.min, Math.min(props.max, props.min + steps * props.step))
|
||||
const rawValue = Math.max(props.min, Math.min(props.max, props.min + steps * props.step))
|
||||
// Fix floating point precision issues, limit to 2 decimal places
|
||||
return Math.round(rawValue * 100) / 100
|
||||
}
|
||||
|
||||
const startDrag = (event: PointerEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user