Skip to content

Commit

Permalink
Add magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
tomodwyer committed Sep 5, 2024
1 parent 0932e05 commit f18352e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/src/scripts/resizer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Magic number for resizing
const MAGIC_PIXELS = 8;

/**
* Debounce a function to slow down how frequently it runs.
*
Expand All @@ -21,13 +24,13 @@ function setContentHeight() {
const iframe = document.querySelector("iframe");
if (iframe) {
const iframeTop = iframe.getBoundingClientRect().top;
iframe.style.height = `${window.innerHeight - iframeTop}px`;
iframe.style.height = `${window.innerHeight - iframeTop - MAGIC_PIXELS}px`;
}

const selectedContent = document.getElementById("selected-contents");
if (selectedContent) {
const contentTop = selectedContent.getBoundingClientRect().top;
selectedContent.style.height = `${window.innerHeight - contentTop}px`;
selectedContent.style.height = `${window.innerHeight - contentTop - MAGIC_PIXELS}px`;
selectedContent.classList.add("overflow-auto");
}
}
Expand All @@ -39,7 +42,7 @@ function setTreeHeight() {
const iframe = document.getElementById("tree-container");
if (iframe) {
const iframeTop = iframe.getBoundingClientRect().top;
iframe.style.height = `${window.innerHeight - iframeTop}px`;
iframe.style.height = `${window.innerHeight - iframeTop - MAGIC_PIXELS}px`;
}
}

Expand Down

0 comments on commit f18352e

Please sign in to comment.