Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials
Created August 15, 2017 16:52
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 wtfaremyinitials/9bd14ed56cef33ad6b4a6b7e26cddacf to your computer and use it in GitHub Desktop.
Save wtfaremyinitials/9bd14ed56cef33ad6b4a6b7e26cddacf to your computer and use it in GitHub Desktop.
// http://slides.com/sdrasner/svg-can-do-that#/38
var shape = document.getElementById("shape");
// media query event handler
if (matchMedia) {
var mq = window.matchMedia("(min-width: 500px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
// media query change
function WidthChange(mq) {
if (mq.matches) {
shape.setAttribute("viewBox", "0 0 490 474");
} else {
shape.setAttribute("viewBox", "0 490 500 500");
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment