Skip to content

matchMedia polyfill for testing media queries in JS

Notifications You must be signed in to change notification settings

icaaq/matchMedia.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 

Repository files navigation

#matchMedia() polyfill

test whether a CSS media type or media query applies

Usage

test 'tv' media type

if (matchMedia('tv').matches) {
  // tv media type supported
}

test a mobile device media query

if (matchMedia('only screen and (max-width: 480px)').matches) {
  // smartphone/iphone... maybe run some small-screen related dom scripting?
}

test landscape orientation

if (matchMedia('all and (orientation:landscape)').matches) {
  // probably tablet in widescreen view
}

Used in:

About

matchMedia polyfill for testing media queries in JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published