1
0
Fork 0

fix(react,utils): Change imperial step to 1/16 in.

This commit is contained in:
Benjamin Fan 2025-05-21 20:14:22 -07:00 committed by Joost De Cock
parent b3a45962ef
commit bfc2296cec
2 changed files with 12 additions and 6 deletions

View file

@ -205,12 +205,18 @@ export const MenuMmInput = (props) => {
/*
* Set a default step that matches the unit.
*
* Note that we could try to use something like 1.5875 for imperial to move in steps of 1/16 inches,
* but we round the mm values to two digits in the options, which would accumulate rounding errors.
*
* Because of this, we use 10ths of inches instead of 16ths of inches.
* Imperial:
* mm, inch, decimal digits precision needed:
* 1.27 mm, 0.1 in, 2 digits
* 3.175 mm, 1/8 in, 3 digits
* 1.5875 mm, 1/16 in, 4 digits
* 0.79375 mm, 1/32 in, 5 digits
* We previously rounded mm values to 2 digits in the options and used
* a 1.27 mm (1/10 in) step because precision didn't support 1/16 in
* or 1/32 in steps.
* We now round mm values to 4 digits and use a 1.5875 mm (1/16 in.) step.
*/
const defaultStep = imperial ? 1.27 : 1 // mm
const defaultStep = imperial ? 1.5875 : 1 // mm
return (
<MenuSliderInput

View file

@ -389,7 +389,7 @@ export function measurementAsMm(value, units = 'metric') {
/** convert a millimeter value to a Number value in the given units */
export function measurementAsUnits(mmValue, units = 'metric') {
return round(mmValue / (units === 'imperial' ? 25.4 : 10), 3)
return round(mmValue / (units === 'imperial' ? 25.4 : 10), 4)
}
/*