MultiSlider icon indicating copy to clipboard operation
MultiSlider copied to clipboard

Setting min, max, minValue, maxValue at time

Open RafaRuiz opened this issue 7 years ago • 1 comments

Hello, I created a modal that tells me what's the minimum I can reach (min), maximum I can reach (max), minimum current value (thumbs[0].value) and maximum current value (thumbs[1].value).

I wasn't aware about the order, but I was doing the following: multiSlider.min = filterModel.minPrice!!.toInt() multiSlider.max = filterModel.maxPrice!!.toInt()

    multiSlider.getThumb(0).value = filterModel.minPriceChosen ?: multiSlider.min
    multiSlider.getThumb(1).value = filterModel.maxPriceChosen ?: multiSlider.max

which makes sense

in case min = 2, max = 2000, minimumCurrent = 200 and maximumCurrent = 1000 it was setting the minimumCurrent to 100 because the maximum is updated later and 200 would be greater than the max of the thumb.

I believe there should be a method for better understanding, code clean and etcetera that for 2 thumbs, you can set all these 4 vars.

The solution for me was doing it the opposite way:

    multiSlider.max = filterModel.maxPrice!!.toInt()
    multiSlider.min = filterModel.minPrice!!.toInt()

    multiSlider.getThumb(1).value = filterModel.maxPriceChosen ?: multiSlider.max
    multiSlider.getThumb(0).value = filterModel.minPriceChosen ?: multiSlider.min

RafaRuiz avatar Jan 11 '18 13:01 RafaRuiz

I debugged a lot trying to figure out what's going on until I found this solution. It worked as expected.

Sabboo avatar Oct 15 '19 17:10 Sabboo