-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use JS to only resize overflowing code blocks
- Loading branch information
1 parent
c985c98
commit bf27fc1
Showing
3 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var codescroll = function () { | ||
console.log("codescroll"); | ||
var elements = document.querySelectorAll(".highlight > div.chroma"); | ||
for (element of elements) { | ||
// Get the width of the screen | ||
let screenWidth = window.innerWidth; | ||
let threshold = screenWidth - 110; | ||
let firstChild = element.firstElementChild; | ||
console.log( | ||
screenWidth, | ||
threshold, | ||
firstChild.offsetWidth, | ||
element, | ||
firstChild, | ||
); | ||
if (firstChild.offsetWidth > threshold) { | ||
element.classList.add("scroll"); | ||
} else { | ||
element.classList.remove("scroll"); | ||
} | ||
} | ||
}; | ||
|
||
codescroll(); | ||
window.onresize = codescroll; |