Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PixievoltNo1
Created June 24, 2014 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PixievoltNo1/431fe9b15fe66bcd1f9c to your computer and use it in GitHub Desktop.
Save PixievoltNo1/431fe9b15fe66bcd1f9c to your computer and use it in GitHub Desktop.
SVG Snippets
// Shortcut functions makeSVGElem & makeUseElem for making SVG elements
var svgNS = "http://www.w3.org/2000/svg";
function makeSVGElem(name) { return document.createElementNS(svgNS, name); }
function makeUseElem(url) {
var elem = makeSVGElem("use");
elem.setAttributeNS("http://www.w3.org/1999/xlink", "href", url);
return elem;
}
// Workaround for jQuery bug #11166 to allow setting viewBox
$.attrHooks.viewbox = { set: function(elem, value) {
elem.setAttribute("viewBox", value);
return value;
} };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment