Created
December 4, 2024 09:47
-
-
Save fabiofidanza/ad244db638b0190d01f833046205c0d6 to your computer and use it in GitHub Desktop.
Check mobile media query in javascript
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
function _isMobile() { | |
const mobileBreapoint = window.getComputedStyle(document.body).getPropertyValue('--mobile-breakpoint'); | |
const mobileMediaQuery = `only screen and (max-width: ${mobileBreapoint})`; | |
console.log(mobileMediaQuery); | |
return window.matchMedia(mobileMediaQuery).matches; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment