Skip to content

Instantly share code, notes, and snippets.

@zaidaldabbagh
Last active May 16, 2019 01:00
Show Gist options
  • Save zaidaldabbagh/a4141582068608c80a1092c411a8e98b to your computer and use it in GitHub Desktop.
Save zaidaldabbagh/a4141582068608c80a1092c411a8e98b to your computer and use it in GitHub Desktop.
Script to identify if content of a particular div is overflowing — See https://stackoverflow.com/questions/143815/determine-if-an-html-elements-content-overflows.
// add overflowing text indicator for cards with longer texts
var win2dOptionValues = document.getElementsByClassName('win2dOption-value');
for (var i=0; i < win2dOptionValues.length; i++) {
var curOverflow = win2dOptionValues[i].style.overflow;
var isOverflowing = win2dOptionValues[i].clientWidth < win2dOptionValues[i].scrollWidth ||
win2dOptionValues[i].clientHeight < win2dOptionValues[i].scrollHeight;
if (isOverflowing) {
win2dOptionValues[i].className += " win2dOption-value--overflowing";
win2dOptionValues[i].style.overflowy = "scroll";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment