Created
September 13, 2018 01:31
-
-
Save marcnewport/9fdf79b4c59d54a7026ab4a9658bde16 to your computer and use it in GitHub Desktop.
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
| // media query event handler | |
| if (window.matchMedia) { | |
| const mq = window.matchMedia("(min-width: 500px)"); | |
| mq.addListener(WidthChange); | |
| WidthChange(mq); | |
| } | |
| // media query change | |
| function WidthChange(mq) { | |
| if (mq.matches) { | |
| // window width is at least 500px | |
| } else { | |
| // window width is less than 500px | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment