Skip to content

Instantly share code, notes, and snippets.

@udittyagi
Last active October 11, 2019 10:00
Show Gist options
  • Save udittyagi/eb91152ba5f8d0d2cd5c766581f0cd34 to your computer and use it in GitHub Desktop.
Save udittyagi/eb91152ba5f8d0d2cd5c766581f0cd34 to your computer and use it in GitHub Desktop.
const handleQueryListener = () => {
const updatedMatches = keys.reduce((acc, media) => {
acc[media] = !!(mediaQueryLists[media] && mediaQueryLists[media].matches);
return acc;
}, {})
console.log('Matches', updatedMatches)
}
keys.forEach(media => {
if(typeof queries[media] === 'string') {
mediaQueryLists[media].addListener(handleQueryListener)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment