Last active
December 19, 2015 12:18
-
-
Save bttmly/5953568 to your computer and use it in GitHub Desktop.
Webkit has problems rendering SVGs with the correct dimensions. More info:
http://stackoverflow.com/questions/7570917/svg-height-incorrectly-calculated-in-webkit-browsers
https://bugs.webkit.org/show_bug.cgi?id=82489 http://www.brichards.co.uk/blog/webkit-svg-height-bug-workaround
This file contains hidden or 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
// jQuery fix for Webkit SVG height bug. | |
// Documented here: https://bugs.webkit.org/show_bug.cgi?id=82489 & http://www.brichards.co.uk/blog/webkit-svg-height-bug-workaround | |
// Found via: http://stackoverflow.com/questions/7570917/svg-height-incorrectly-calculated-in-webkit-browsers | |
// Original Gist: https://gist.github.com/pfulton/4259378 | |
// Call the fix function on resize and/or ready | |
svgElements = $('svg') | |
function fixWebkitHeightBug(){ | |
svgElements.each(function() { | |
$(this).parent().height(this.prop('viewBox').baseVal / this.prop('viewBox').baseVal * $(this).parent().width() ) | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment