Slider, how to make “step” size change - JQuery

808 views Asked by At

I want to do something: http://astro.unl.edu/naap/hr/animations/hrExplorer.html

This example is in Flash but I'm doing mine in JQuery.

See my code: http://jsfiddle.net/NYZrz/9/

I'm having problem with the Slider "step" . In first link the value start in 1.0, the min=0.00010 and the max: 1000000

I want to horizontal Slider to look like:

0.00010 | 0.00012 | 0.00014 | 0.00017 | .... | 0.0090 | 0.011 | .... | 0.10 | 0.12 | 0.14 | ... | 1.0 | 1.2 | 1.4 | ... | 9.0 | 11 | 13 | 16 | .... | 5400 | ... | 1000000

But my code does not do this.

Can you help me??

Thanks....

1

There are 1 answers

4
cambraca On BEST ANSWER

Use num.toPrecision(2) instead of toFixed to always get 2 significant digits. I updated your fiddle.

EDIT. To make numbers below 10, quite simply:

var _num = (num < 10) ? num.toPrecision(2) : Math.round(num)

(num < 10 instead of num < 1)

I updated your fiddle again.