Scroll bars should not be shown in the tab - the size should be exact
wywywywy opened this issue · 1 comments
wywywywy commented
To Reproduce
- Use Chrome latest
- Scroll bars appear
- Adjust window size, zoom level, etc, scroll bars still there
Expected behavior
Scroll bars should not be there, because the iframe size should be exact
Desktop (please complete the following information):
- Windows 11
- Chrome latest
- commit 1151530
Additional context
Does not happen with Firefox.
I think Chrome handles sizing a bit differently. If we look at the left/height/width/etc of the iframe from the dev console, we can (surprisingly) see some decimal numbers.
This below should be a good fix that works on both Chrome and Firefox.
const recalculate = () => {
// If we are on the openoutpaint tab, recalculate
if (tabEl.style.display !== "none") {
frame.style.height = window.innerHeight + "px";
const current = document.body.scrollHeight;
const bb = frame.getBoundingClientRect();
const iframeh = bb.height;
const innerh = window.innerHeight;
frame.style.height = `${Math.floor(iframeh + (innerh - current)) - 1}px`;
frame.style.width = `${Math.floor(window.innerWidth) - 1}px`;
frame.style.left = `${Math.floor(parseInt(frame.style.left, 10) - bb.x)}px`;
}
};