githuboftigran / rn-range-slider

A native slider with range
MIT License
237 stars 133 forks source link

It would be great if the value supports floating point numbers #48

Closed firede closed 3 years ago

firede commented 4 years ago

Example:

const [brightness, setBrightness] = useBrightness();

// ...

<RangeSlider
    min={0.001}
    max={1}
    step={0.001}
    rangeEnabled={false}
    initialLowValue={brightness}
    onValueChanged={(low, high, fromUser) => {
        fromUser && setBrightness(low);
    }} />
gplutov commented 4 years ago

Facing the same issue. Did someone found a solution for this?

firede commented 4 years ago

If you don't need the label (labelStyle="none"), you can hack it with JavaScript:

const [value, setValue] = useState(1 * 100) // init value: 1%

<RangeSlider
    min={1} // min value: 0.01%
    max={100 * 100} // max value: 100%
    rangeEnabled={false}
    initialLowValue={value}
    onValueChanged={(low, high, fromUser) => {
        fromUser && setValue(low);
    }} />

<Text>expected value: {value / 100}%</Text>
githuboftigran commented 3 years ago

v2 uses JS only, so you can use any numbers now :)