Created
December 11, 2012 15:31
-
-
Save pfulton/4259378 to your computer and use it in GitHub Desktop.
Webkit SVG height bugfix
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
// 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 | |
function fixWebkitHeightBug(){ | |
var svgW = 658; | |
var svgH = 500; | |
var curSVGW = $('#svg-container').width(); | |
var newSVGH = heightInRatio(svgH,svgW,curSVGW); | |
$('#svg-container').height(newSVGH); | |
function heightInRatio(oH,oW,nW){ | |
return (oH / oW * nW); | |
} | |
}; | |
$(window).resize(function() { | |
fixWebkitHeightBug(); | |
}); | |
$(document).ready(function() { | |
fixWebkitHeightBug(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment