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.69k stars 657 forks source link

Value of slider is coming in decimals even if min, max and steps are in integer #1108

Closed sunilpandey closed 3 years ago

sunilpandey commented 4 years ago

I am creating slider with following configuration noUiSlider.create(slider, { start: 20, connect: true,

  range: {
      'min': 1000,
      'max': 10000
  },
  connect: [true, false],
  step: 1000,
  tooltips: true,
  format: wNumb({decimal: 0}),

});

However when I am moving the handle to 4000 slider is returning value 3999.9999..5 instead. Please find related plunkr https://plnkr.co/edit/WEGWt1edqXGm3aXQ value in decimal

leongersen commented 4 years ago

The {decimal: 0} you are using should be {decimals: 0} (you are missing the s).

sunilpandey commented 4 years ago

Thanks for quick support however Issue still persist. It looks like you are formatting and parsing with 2 decimal digits that is why when custom formatter is not applied it is working fine. Once custom formatter is applied this becomes a problem and internal value is wrong with fraction. In ideal scenario If all three value min, max and step are numeric then it should never return a fractional value.

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.