Skip to content

Instantly share code, notes, and snippets.

@ghorvat
Created December 4, 2015 18:48
Show Gist options
  • Save ghorvat/194cf17901ae16ca2563 to your computer and use it in GitHub Desktop.
Save ghorvat/194cf17901ae16ca2563 to your computer and use it in GitHub Desktop.
jQuery(window).bind("resize load", function () {
jQuery(".middleCaptionSquareImageTile .image-item").each(function (i) {
var desc = jQuery(this).find(".image-description");
var ovaj = jQuery(this);
var descHeight = jQuery(desc).outerHeight();
var parentHeight = jQuery(desc).parent().outerHeight();
var chi = jQuery(this).children(".image-description");
jQuery(chi).each(function (m, el) {
console.log(el.clientHeight);
if (descHeight > parentHeight) {
var differenceInheight = descHeight - parentHeight;
console.log(differenceInheight);
if (jQuery(ovaj).children().hasClass("image-description")) {
jQuery(ovaj).children(".image-description").css({
"overflow": "auto",
"max-height": descHeight - differenceInheight * 20
});
}
} else if (el.clientHeight < parentHeight) {
if (jQuery(ovaj).children().hasClass("image-description")) {
jQuery(ovaj).children(".image-description").css({
"overflow": "normal",
"max-height": "auto"
});
}
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment