Skip to content
Snippets Groups Projects
Commit 65b32d84 authored by David Smadja's avatar David Smadja
Browse files

adjust slider min and max to fit testcase value

parent 83868d4a
No related branches found
No related tags found
1 merge request!308Align slider to test case
......@@ -199,9 +199,7 @@
return
}
const updatedMin = slider.min
const updatedMax = slider.max
const updatedStepValue = (updatedMax - updatedMin) / 100 ?? slider.stepValue
const updatedStepValue = (slider.max - slider.min) / 100
const value = getSituationVariableValue(
situation,
......@@ -210,20 +208,24 @@
year,
) as number
const offsetFromMin = value - slider.min
const vectorIndex = Math.max(
0,
Math.min(100, Math.round(value / updatedStepValue)),
Math.min(100, Math.round(offsetFromMin / updatedStepValue)),
)
let updatedMin = value - vectorIndex * updatedStepValue
updatedMin = updatedMin < 0 ? updatedMin + updatedStepValue : updatedMin
const updatedMax = updatedMin + updatedStepValue * 100
// Update situation
setSituationVariableValue(
entityByKey,
situation,
variable,
slider.id,
year,
Math.round(updatedStepValue * vectorIndex),
)
// setSituationVariableValue(
// entityByKey,
// situation,
// variable,
// slider.id,
// year,
// Math.round(updatedStepValue * vectorIndex + updatedMin),
// )
situation.slider = {
...slider,
min: updatedMin,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment