0
document.getElementById('idcardsliderScroll').scrollBy(399.4, 0 );
// result scroll 399px

and 

document.getElementById('idcardsliderScroll').scrollBy(399.5, 0 );
// result scroll 400px

I need to ScrollBy the decimal number without rounding, is it possible?

I don't know what to try

  • Why do you need to scroll to decimal? You can't see 0.5 px difference. – kennarddh Dec 28 '22 at 06:23
  • How are you detecting the result? According to [the standard](https://w3c.github.io/csswg-drafts/cssom-view/#normalize-non-finite-values) `scrollBy` values are [unrestricted doubles](https://webidl.spec.whatwg.org/#idl-unrestricted-double) ("_unrestricted double constant values in IDL are represented with decimal tokens_") – Teemu Dec 28 '22 at 06:33

1 Answers1

0

This is how the scrollBy( ) works. You can't do anything to change it.

syntax :

window.scrollBy({
  top: 100,
  left: 100,
  behavior: 'smooth'
});
Snehil Agrahari
  • 307
  • 1
  • 15