Skip to content

Commit 43a3f41

Browse files
authored
Merge pull request #25 from ethmarks/ethmarks-footer-overflow
add overflow detection to ethmarks-footer component
2 parents 7b8052e + ff5c914 commit 43a3f41

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

layouts/partials/ethmarks-components-js.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,32 @@
1212
class EthmarksFooter extends HTMLElement {
1313
connectedCallback() {
1414
this.innerHTML = %s;
15+
16+
// Add overflow detection functionality
17+
function updateOverflowClasses() {
18+
const heightOverflowClass = "height-overflow";
19+
const body = document.body;
20+
const containerHeight = window.innerHeight;
21+
const contentHeight = Math.max(
22+
document.documentElement.scrollHeight,
23+
document.body.scrollHeight
24+
);
25+
26+
if (contentHeight === 0) { return; }
27+
28+
if (contentHeight > containerHeight) {
29+
body.classList.add(heightOverflowClass);
30+
} else {
31+
body.classList.remove(heightOverflowClass);
32+
}
33+
}
34+
35+
const resizeObserver = new ResizeObserver(() => {
36+
updateOverflowClasses();
37+
});
38+
39+
resizeObserver.observe(document.body);
40+
updateOverflowClasses();
1541
}
1642
}
1743

0 commit comments

Comments
 (0)