Last active
October 13, 2016 08:50
-
-
Save Pustelto/9e374df765f89dd8ea1c0550ace60550 to your computer and use it in GitHub Desktop.
Art direction for responsive SVG (usefull for responsive logos). Taken from www.arborvitae.skauting.cz, Modernizer media queries is necessary.
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
// SVG art-direction | |
const logoSvg = document.getElementById( 'av-logo' ); | |
function artDirectSvg() { | |
if( Modernizr.mq( '(max-width: 300px)' ) ) { | |
logoSvg.setAttribute( 'viewBox', '0 0 79 85' ); | |
} | |
if( Modernizr.mq( '(min-width: 300px)' ) && Modernizr.mq( '(max-width: 560px)' ) ) { | |
logoSvg.setAttribute( 'viewBox', '97 -230 403 310' ); | |
} | |
if( Modernizr.mq( '(min-width: 561px)' ) ) { | |
logoSvg.setAttribute( 'viewBox', '0 0 500 85' ); | |
} | |
} | |
artDirectSvg(); | |
window.addEventListener( 'resize', artDirectSvg ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment