leongersen / noUiSlider

noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. It is fully GPU animated: no reflows, so it is fast; even on older devices. It also fits wonderfully in responsive designs and has no dependencies.
https://refreshless.com/nouislider/
MIT License
5.64k stars 658 forks source link

format with intergers skips a step #1201

Closed frenchcdsl44 closed 2 years ago

frenchcdsl44 commented 2 years ago

Hi

On this fiddle https://jsfiddle.net/s59j0rof/

I set start: [0, 20, 150], but i get [0, 19, 149]

I think it has to do with the format because without the problem does not show

format: { from: function(value) { return parseInt(value); }, to: function(value) { return parseInt(value); } },

How do I use integers as input and output?

Thanks for you nice work anyway.

leongersen commented 2 years ago

With parseInt you are dropping the decimals when formatting. Use Number() in from instead.

frenchcdsl44 commented 2 years ago

Hi

Thanks for the quick reply. I had to add Math.rounding in the to. I updated the jsfiddle : https://jsfiddle.net/sw4k0egj/1/

with

 format: {
    from: function(value) {
      return Number(value);
    },
    to: function(value) {
      return Math.round(Number(value));
    }
  },

And it works fine. Thank you for pointing me in the decimal issue.

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.