Created
August 21, 2014 09:24
-
-
Save niallobrien/c33ff0b284f78006f924 to your computer and use it in GitHub Desktop.
Execute JS based on the current screen-size (Foundation's media queries)
This file contains hidden or 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
var mediaStateContainer = document.querySelector('.mq'), | |
mediaState = window.getComputedStyle(mediaStateContainer, ':before').getPropertyValue('content'); | |
if (mediaState === 'small' ) { | |
// JS to run when we're on mobile. | |
} |
This file contains hidden or 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
.mq { | |
&:before { | |
content: 'small'; | |
position: absolute; | |
display: none; | |
width: 0; | |
height: 0; | |
} | |
} | |
@media #{$medium-up} { | |
.mq:before { | |
content: 'medium'; | |
} | |
} | |
@media #{$large-up} { | |
.mq:before { | |
content: 'large'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment