Last active
March 18, 2018 02:58
-
-
Save jackfearing/3986bc1d56cf4cc24c8a88151fe8499a to your computer and use it in GitHub Desktop.
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
// https://gist.github.com/jpdery/40ae985c43b2168b7869f70ca0e5aab3 | |
// IE 11 Min Height Flex Fix | |
if (window.navigator.userAgent.indexOf('Trident/7.0') > 0 || | |
window.navigator.userAgent.indexOf('Trident/6.0') > 0) (function($) { | |
$('*:not(.no-ie-flex-fix').each(function(i, element) { | |
element = $(element) | |
var timeout = null | |
var display = element.css('display') | |
var minimum = parseInt(element.css('min-height')) | |
if ((display === 'flex' || display === '-ms-flexbox') && minimum > 0) { | |
var measure = function() { | |
var minimum = parseInt(element.css('min-height')) | |
if (minimum > 0) { | |
element.css('height', '') | |
var height = element.get(0).scrollHeight | |
if (height < minimum) { | |
height = minimum | |
} | |
console.log('Setting height to', height) | |
element.css('height', height) | |
} else { | |
element.css('height', '') | |
} | |
timeout = null | |
} | |
$(window).on('resize', function() { | |
if (timeout == null) { | |
timeout = setTimeout(measure, 16) | |
} | |
}) | |
measure() | |
} | |
}) | |
})(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment