Created
August 15, 2017 16:52
-
-
Save wtfaremyinitials/9bd14ed56cef33ad6b4a6b7e26cddacf 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
// 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