matchMedia polyfill for testing media queries in JS
JavaScript
2,359
73 commits
updated Dec 22, 2020
// Likely want to requier both polyfills..
require('matchmedia-polyfill');
require('matchmedia-polyfill/matchMedia.addListener');
if (matchMedia('tv').matches) {
// tv media type supported
}
if (matchMedia('only screen and (max-width: 480px)').matches) {
// smartphone/iphone... maybe run some small-screen related dom scripting?
}
if (matchMedia('all and (orientation:landscape)').matches) {
// probably tablet in widescreen view
}
Paul Hayes tackled this using CSS transitions and their transitionEnd event
His code: https://github.com/fofr/matchMedia.js -- though currently it doesnt support IE6-9, since they dont have transitions, obviously. :)
1,046 followers · starred Jan 2016
2,102 followers · starred Apr 2011
893 followers · starred Apr 2011
2,937 followers · starred Feb 2016
matchMedia polyfill for testing media queries in JS
JavaScript
2,359
73 commits
updated Dec 22, 2020
// Likely want to requier both polyfills..
require('matchmedia-polyfill');
require('matchmedia-polyfill/matchMedia.addListener');
if (matchMedia('tv').matches) {
// tv media type supported
}
if (matchMedia('only screen and (max-width: 480px)').matches) {
// smartphone/iphone... maybe run some small-screen related dom scripting?
}
if (matchMedia('all and (orientation:landscape)').matches) {
// probably tablet in widescreen view
}
Paul Hayes tackled this using CSS transitions and their transitionEnd event
His code: https://github.com/fofr/matchMedia.js -- though currently it doesnt support IE6-9, since they dont have transitions, obviously. :)
1,046 followers · starred Jan 2016
2,102 followers · starred Apr 2011
893 followers · starred Apr 2011
2,937 followers · starred Feb 2016