Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Vertical scrollbars when browser zoom level <> 100% #306

Closed
ncirkel opened this issue Jul 22, 2016 · 4 comments
Closed

Vertical scrollbars when browser zoom level <> 100% #306

ncirkel opened this issue Jul 22, 2016 · 4 comments

Comments

@ncirkel
Copy link

ncirkel commented Jul 22, 2016

In Google Chrome, on zoom levels other than 100%, vertical scrollbars sometimes (not always) appear, allowing for 1px scroll up and down. So far, while testing, the best bet to get steady results is setting line-height inside the textarea to 150%. I mention this because it may tell something about the origin of the problem.

It feels like somewhere the calculated height is rounded down in stead of up, but this is just guessing.

@jackmoore
Copy link
Owner

Autosize doesn't do any rounding, it uses getComputedStyle specifically to get subpixel values, but it looks like the browser is maybe returning an rounded value for scrollHeight? Not sure yet, may be related to this Chromium bug:

https://bugs.chromium.org/p/chromium/issues/detail?id=447902

@jackmoore
Copy link
Owner

Ok, so this definitely seems like a Chromium bug. If I set zoom to 110% and set the textarea height style to a whole number of pixels, window.getComputedStyle may return a floating point value.

For example:

var ta = document.querySelector('textarea');
ta.style.height = '1336px';
window.getComputedStyle(ta).height; // 1335.99px

This exact example may not work for you depending on your doc. May also depend on your pixelDeviceRatio.

I'll round the getComputedStyle result to work around this.

@jackmoore
Copy link
Owner

That should get it. Thanks!

@ncirkel
Copy link
Author

ncirkel commented Jul 26, 2016

Thanks for the quick response and fix! Just tested it in my app and the problem is gone.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants