I'm using this AngularJS Slider, the horizontal one.
I took the example that has the points divided by a different distance. That example, started from a wide distance, to end with a small distance:
What I wanted to do, is to invert the scale keeping the numbering. This is my code: JSFIDDLE
As you can see, I changed the function customValueToPosition
:
customValueToPosition: function(val, minVal, maxVal) {
val = Math.sqrt(val);
minVal = Math.sqrt(minVal);
maxVal = Math.sqrt(maxVal);
var range = minVal - maxVal;
return (val - maxVal) / range;
}
There are two problems: The numbers are inverted. I would like to leave from 0 instead of starting 5.
Then there is a problem with the click of the first and the last value. If you click slightly before the first element (or just after the last item), the selection falls on the opposite value. So, if I just click just before the first element first, select the last one. And viceversa.