zero01101/openOutpaint-webUI-extension

Scroll bars should not be shown in the tab - the size should be exact

wywywywy opened this issue · 1 comments

Describe the bug
image

To Reproduce

  1. Use Chrome latest
  2. Scroll bars appear
  3. 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`;
		}
	};

huh, can't confirm locally on chrome 108.0.59whatever it claims to be up-to-date (win10x64), but it's definitely a reasonable and noninvasive enough fix that i'm pretty comfy with just dropping it in :) should be added in ab5b22e