I have a slider with values ranging from 0 to 100.
I want to map them to a range from 100 to 10,000,000.
I've seen some functions scattered around the net but they're all in C++.
I need it in Javascript.
Any ideas?
javascriptlogarithmslider
I have a slider with values ranging from 0 to 100.
I want to map them to a range from 100 to 10,000,000.
I've seen some functions scattered around the net but they're all in C++.
I need it in Javascript.
Any ideas?
Best Solution
You can use a function like this:
The resulting values match a logarithmic scale:
The reverse function would, with the same definitions for
minp
,maxp
,minv
,maxv
andscale
, calculate a slider position from a value like this:All together, wrapped in a class and as a functional code snippet, it would look like this: