I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit f782afef authored by str4d's avatar str4d
Browse files

Add scrollbar width to iframe height, so vertical scrollbar doesn't appear

FIXME: add horizontal scrollbar detection so only adding the extra height
when it is actually needed.
parent 7e7cabfd
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,31 @@ ...@@ -50,7 +50,31 @@
// but does not include the margin. Therefore, any content within the iframe // but does not include the margin. Therefore, any content within the iframe
// should have no margins at the very top or very bottom to avoid a scrollbar. // should have no margins at the very top or very bottom to avoid a scrollbar.
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
f.style.height = doc.body.offsetHeight + "px"; var totalHeight = doc.body.offsetHeight;
// Detect if horizontal scrollbar is present, and add its width to height if so.
// This prevents a vertical scrollbar appearing when the min-width is passed.
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
if (true) {
// Create the measurement node
var scrollDiv = document.createElement("div");
scrollDiv.className = "scrollbar-measure";
scrollDiv.style.width = "100px";
scrollDiv.style.height = "100px";
scrollDiv.style.overflow = "scroll";
scrollDiv.style.position = "absolute";
scrollDiv.style.top = "-9999px";
document.body.appendChild(scrollDiv);
// Get the scrollbar width
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
totalHeight += scrollbarWidth;
// Delete the div
document.body.removeChild(scrollDiv);
}
f.style.height = totalHeight + "px";
} }
function setupFrame() { function setupFrame() {
f = document.getElementById("i2ptunnelframe"); f = document.getElementById("i2ptunnelframe");
......
...@@ -32,7 +32,31 @@ ...@@ -32,7 +32,31 @@
// but does not include the margin. Therefore, any content within the iframe // but does not include the margin. Therefore, any content within the iframe
// should have no margins at the very top or very bottom to avoid a scrollbar. // should have no margins at the very top or very bottom to avoid a scrollbar.
var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document;
f.style.height = doc.body.offsetHeight + "px"; var totalHeight = doc.body.offsetHeight;
// Detect if horizontal scrollbar is present, and add its width to height if so.
// This prevents a vertical scrollbar appearing when the min-width is passed.
// FIXME: How to detect horizontal scrollbar in iframe? Always apply for now.
if (true) {
// Create the measurement node
var scrollDiv = document.createElement("div");
scrollDiv.className = "scrollbar-measure";
scrollDiv.style.width = "100px";
scrollDiv.style.height = "100px";
scrollDiv.style.overflow = "scroll";
scrollDiv.style.position = "absolute";
scrollDiv.style.top = "-9999px";
document.body.appendChild(scrollDiv);
// Get the scrollbar width
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
totalHeight += scrollbarWidth;
// Delete the div
document.body.removeChild(scrollDiv);
}
f.style.height = totalHeight + "px";
} }
function setupFrame() { function setupFrame() {
f = document.getElementById("i2psnarkframe"); f = document.getElementById("i2psnarkframe");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment