OK, if you want to follow your algorithm, this is a possible solution
var value:Int = 0 func readSliderValue(val:Int) { while(value != val) { value = value + (val < value ? -1 : 1)
But Matt is probably right, and the problem is in the design and / or algorithm.
Why the values ββare not consistent: the slider represents the actual value of the slider using the mouse / finger position. When you move your finger very fast, like in your video / gif, the internal process that scans your position / gesture of your finger is slower than your finger. Thus, between two checks of internal algorithms for determining the position of the finger (finger), more than one position of the slider intersects. Thus, the idea of ββa slider is not to show you how your finger went, but where it is now. Thus, the slider works correctly, perspectives are created from it :)
source share