From 07691e80c3bf9be16c629169e259105ca5327bf0 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sat, 9 Sep 2023 03:15:31 -0400 Subject: [PATCH] Does it make sense to allow configuring the round and precision? --- web/scripts/widgets.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/scripts/widgets.js b/web/scripts/widgets.js index 4dc173b8..30caa6a8 100644 --- a/web/scripts/widgets.js +++ b/web/scripts/widgets.js @@ -2,7 +2,7 @@ import { api } from "./api.js" function getNumberDefaults(inputData, defaultStep) { let defaultVal = inputData[1]["default"]; - let { min, max, step, round, precision } = inputData[1]; + let { min, max, step } = inputData[1]; if (defaultVal == undefined) defaultVal = 0; if (min == undefined) min = 0; @@ -10,9 +10,9 @@ function getNumberDefaults(inputData, defaultStep) { if (step == undefined) step = defaultStep; // precision is the number of decimal places to show. // by default, display the the smallest number of decimal places such that changes of size step are visible. - if (precision == undefined) precision = Math.max(-Math.floor(Math.log10(step)),0) + let precision = Math.max(-Math.floor(Math.log10(step)),0) // by default, round the value to those decimal places shown. - if (round == undefined) round = Math.round(1000000*Math.pow(0.1,precision))/1000000; + let round = Math.round(1000000*Math.pow(0.1,precision))/1000000; return { val: defaultVal, config: { min, max, step: 10.0 * step, round, precision } }; }