thehung111 / NHRangeSlider

A custom range slider in Swift
https://thehung111.github.io/NHRangeSlider/
MIT License
156 stars 45 forks source link

how i can stop slider on needed value? #13

Open yaddaa opened 7 years ago

yaddaa commented 7 years ago

Hello. At first thanks for your slider, i create custom and very happy now) Help me please. If i have some poing on a slider and i need dont let lover and upper value going over this point to right and left respectively. I am try do it in valueChanged, but its not so cool, because it jerks.

override func rangeSliderValueChanged(_ rangeSlider: NHRangeSlider) {

        super.rangeSliderValueChanged(rangeSlider)

        if rangeSlider.lowerValue > Double(kidLeftIndex) {
            rangeSlider.lowerValue = Double(kidLeftIndex)
            return
        }

        if rangeSlider.upperValue < Double(kidLeftIndex + 1) {
            rangeSlider.upperValue = Double(kidLeftIndex + 1)
            return
        }
    }