Chrome subpixel scroll issue
The issue could be reproduced on Chrome 69.0.3497.100 with zoom in/out
by dhilt
HTML
Source: <a href="https://stackoverflow.com/questions/52470549/subpixel-scroll-issue-cant-set-scrolltop-properly-on-chrome-69-win-10-pro">stackoverflow question</a>.
<p>
Here we are setting scroll position to some value programmatically (viewport.scrollTop = 75) and getting the result that does not match the expectaion depends on browser's zoom setting.
</p>
<p>
The issue could be reproduced only on Chrome browser.
To see the issue you need to zoom in/out and relaunch the demo.
</p>
<table>
<tr>
<th>scale</th>
<th>scrollTop</th>
</tr>
<tr>
<td>50%</td>
<td>74</td>
</tr>
<tr>
<td>75%</td>
<td>74.66666412353516</td>
</tr>
<tr>
<td>80%</td>
<td>75</td>
</tr>
<tr>
<td>90%</td>
<td>74.44444274902344</td>
</tr>
<tr>
<td>100%</td>
<td>75</td>
</tr>
<tr>
<td>110%</td>
<td>74.54545593261719</td>
</tr>
<tr>
<td>125%</td>
<td>74.4000015258789</td>
</tr>
<tr>
<td>150%</td>
<td>74.66666412353516</td>
</tr>
<tr>
<td>175%</td>
<td>74.85713958740234</td>
</tr>
<tr>
<td>200%</td>
<td>75</td>
</tr>
</table>
<div id=viewport>
<div id=content></div>
</div>
<div id=log></div>
CSS
#viewport {
overflow-y: auto;
height: 20px;
}
#content {
height: 150px;
}
#log {
color: #800;
}
JavaScript
const viewport = document.getElementById("viewport");
const log = document.getElementById("log");
const doLog = () => {
log.innerHTML = 'Scroll position (scrollTop): ' + viewport.scrollTop;
};
doLog();
setTimeout(() => {
viewport.scrollTop = 75;
doLog();
}, 1500);