Skip to content

Commit f4a9bcf

Browse files
committed
Fixed coloured percentage
1 parent 55f4c2d commit f4a9bcf

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/SingleRangeSlider.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ const SingleRangeSlider = function (props: SingleRangeSliderProps) {
5252
}
5353

5454
/**
55-
* Returns the selected slice of the slider, in percent from 0 to 100.
55+
* Returns the selected slice of the slider, in percent considering range from defaultMinValue to defaultMaxValue.
5656
*
57-
* @param newValue - New value set on the slider.
58-
* @returns Percent of the slider that need to be colored, from 0 to 100.
57+
* @returns Percent of the slider that need to be colored.
5958
*/
60-
const getSelectedSliderPercent = (newValue: number) => newValue / defaultMaxValue * 100
59+
const getSelectedSliderPercent = () => ((value - defaultMinValue) * 100) / (defaultMaxValue - defaultMinValue)
6160

6261
/**
6362
* If `showLabels` is `true`, returns a `<div>` that contains a label with the current value of the slider.
@@ -70,7 +69,7 @@ const SingleRangeSlider = function (props: SingleRangeSliderProps) {
7069
}
7170
}
7271

73-
const selectedPercent = `${getSelectedSliderPercent(value)}%`
72+
const selectedPercent = `${getSelectedSliderPercent()}%`
7473
const disabledClass = disabled ? 'disabled' : ''
7574

7675
return (

0 commit comments

Comments
 (0)