0

Hello stackoverflow Community,

I am currently facing a problem with the jQuery mobile slider. I have strongly modified the slider. It's working with arrays that contain values the slider is allowed to take.

If you slide to a position that is not in the array it will slide to the nearest value in the array.

My problem now is: The array contains floating point numbers

var m2 = [19.5, 16.5, 14.5, 15, 10, 13];

If my slider needs to slide to 16.5, it instead slides to 17. The actual value of the slider is indeed 16.5 but the bar slides to 17. I don't think the problem is caused by my code since all the values are outputted correctly.

My question now is: Did anyone have a similar problem with the slider? Are there any possible workarounds (or even fixes) for that problem?

I put up the script. You can access it here: http://workidtest.de/ui/new.html

The slider which is affected is the one in the middle.

I also put up the code here: http://pastie.org/5171015

Thanks in advance, Thomas

thpl
  • 5,810
  • 3
  • 29
  • 43

1 Answers1

1

The problem is that jQuery mobile slider rounds up slider value.

I suppose if you want to use 0.5 scale you can multiply all your max value by 2 and assume that 0 stands for 0, 1 stands for 0.5 and 2 stands for 1.

And just multiply your array values by two.

maxwell
  • 857
  • 8
  • 16