Skip to content

Instantly share code, notes, and snippets.

@chalkygames123
Last active December 28, 2020 09:38
Show Gist options
  • Save chalkygames123/4783caaf02f797d6200131a19f08b9dd to your computer and use it in GitHub Desktop.
Save chalkygames123/4783caaf02f797d6200131a19f08b9dd to your computer and use it in GitHub Desktop.
const minWidth = 375
const el = document.querySelector('meta[name="viewport"]')
const updateContent = () => {
if (window.screen.width < minWidth) {
el.setAttribute('content', `width=${minWidth}`)
} else {
el.setAttribute('content', 'width=device-width')
}
}
updateContent()
window.addEventListener('orientationchange', updateContent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment