I'm trying to fix a discrepancy between oldVal and newVal in a 'range slider' and 'number spinner input' both binded to each other. I noticed a bug where the oldVal and newVal had a large discrepancy. I would expect a difference of 1 or maybe 5 as the step is set to 5.
This bug becomes noticable when I bind the slider and spinner, but looking at the console, really binding them just makes the underlying problem with newVal and oldVal visible: the further we drag the slider to the right, the greater the discrepancy.
Here is what I tried to bind the slider & spinner:
var spinnerVal = newVal;
var newCss = spinnerVal / 100 + "%";
document.querySelector('.range-quantity').style.width = newCss;
document.querySelector('.range-handle').style.left = newCss;
slider & spinner bound
http://jsfiddle.net/PaulOD/PpCC4/4/
I'm not sure if this is the best way to bind them, is there a more standard way?
Here is a fiddle where I omit the above code, but they are now not binded to eachother. We can see that the slider moves much more naturally, however the console reports the same discrepancy between oldVal and newVal.
http://jsfiddle.net/PaulOD/PpCC4/5/
Any help most appreciated. It would also be great if I could find a way to target the slider's true value controls, it feels a bit hacky to just change the css. In jQuery I used to target 'ui.value' and that sorted these issues out great, but I'm trying to do this without jQuery this time.
I'm using the powerange slider. http://abpetkov.github.io/powerange/ EDIT: but I think the choice of slider is not significant as I've reproduced the bug with the html range slider here: http://plnkr.co/edit/ke5n3x?p=preview
Thanks, Paul