Skip to content

Instantly share code, notes, and snippets.

@pandauxstudio
Last active May 16, 2019 01:00
Show Gist options
  • Save pandauxstudio/2defa863a39aa2e94c3415d88371ee65 to your computer and use it in GitHub Desktop.
Save pandauxstudio/2defa863a39aa2e94c3415d88371ee65 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