Last active
March 21, 2023 23:54
-
-
Save ImKubass/4b7e89ef41d0fa8ee28776d9cf3f14de 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
const mobileQuery = window.matchMedia("(max-width: 74.999em)") // Change to your needs | |
const handleMobileChange = (mediaQueryList: MediaQueryListEvent | MediaQueryList) => { | |
if (mediaQueryList.matches) { | |
// Its Mobile | |
} else { | |
// Its Desktop | |
} | |
} | |
mobileQuery.addEventListener("change", handleMobileChange) | |
handleMobileChange(mobileQuery) // Init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment