1

Chrome 65.0.3325.181 on Windows 10.0.16299.309. Monitor: 27″, 3840×2160.

Display scaled to 150%, typing in Chrome’s console:

document.documentElement.scrollTop = 1
1
document.documentElement.scrollTop
0.6666666865348816

Chrome console

document.documentElement.scrollTop = 9
9
document.documentElement.scrollTop
8.666666984558105

Another test with window.scrollBy(x, y) and window.scrollY, starting at the top of the page:

(function f() {
  scrollBy(0, 1)
  console.log(scrollY)
  if (scrollY < 10) {
    f()
  }
})()

Output (15 lines – factor of 1.5 of the expected number):

0.6666666865348816
1.3333333730697632
2
2.6666667461395264
3.3333332538604736
4
4.666666507720947
5.333333492279053
6
6.666666507720947
7.333333492279053
8
8.666666984558105
9.333333015441895
10

Yet another test with window.scroll(x, y):

(function f(n) {
  scroll(0, n)
  console.log(scrollY)
  if (scrollY < 10) {
    f(n + 1)
  }
})(1)

Output (10 lines – as expected because of no accumulation):

0.6666666865348816
2
2.6666667461395264
4
4.666666507720947
6
6.666666507720947
8
8.666666984558105
10

Display scaled to 125%:

document.documentElement.scrollTop = 1
1
document.documentElement.scrollTop
0.800000011920929

It seems to me that the value that is really set is “calculated” by value - 1 + 1/scale if value * scale is not integral.

Is that a bug on my site, Windows’s or Chrome’s?

xehpuk
  • 7,814
  • 3
  • 30
  • 54
  • It looks more like it's 100/scale. – nixkuroi Apr 05 '18 at 20:00
  • @nixkuroi I should have mentioned that e.g. 9 results in 8.666666984558105. And it's the inverse of `scale`, not `scale` itself. – xehpuk Apr 05 '18 at 20:08
  • Have you seen this: https://stackoverflow.com/questions/20514596/document-documentelement-scrolltop-return-value-differs-in-chrome ? – nixkuroi Apr 05 '18 at 21:13
  • @nixkuroi Doesn't help me, unfortunately. I have the exact same problem with [`window.scroll(0, 1)`](https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll): `window.scrollY === 0.6666666865348816` – xehpuk Apr 05 '18 at 23:08
  • Out of curiosity, why aren't you adding ".px" to your scrollTop? – nixkuroi Apr 06 '18 at 15:44
  • @nixkuroi `scrollTop` is a numeric property which represents pixels. – xehpuk Apr 09 '18 at 13:33
  • Understood. I've seen browser compatibility issues around that before, but maybe those are all ironed out by now. – nixkuroi Apr 09 '18 at 15:51

0 Answers0