Skip to content

Commit

Permalink
you deserve a readme, now dontcha.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Apr 1, 2011
1 parent 56af0aa commit e72ca58
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
33 changes: 33 additions & 0 deletions README.md
@@ -0,0 +1,33 @@
#matchMedia() polyfill

## test whether a CSS media type or media query applies

* **Authors**: Scott Jehl, Paul Irish, Nicholas Zakas
* **Spec**: [dev.w3.org/csswg/cssom-view/#dom-window-matchmedia](http://dev.w3.org/csswg/cssom-view/#dom-window-matchmedia)
* **Native support**: in Chrome [since m10](http://trac.webkit.org/changeset/72552).



## 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:

* [Respond.js](https://github.com/scottjehl/Respond)
* [MarshallJS](https://github.com/PaulKinlan/marshall)
* [Modernizr](http://www.modernizr.com/)
23 changes: 0 additions & 23 deletions matchMedia.js
Expand Up @@ -3,9 +3,6 @@
* authors: Scott Jehl, Paul Irish, Nicholas Zakas
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* dev.w3.org/csswg/cssom-view/#dom-window-matchmedia
* in Chrome since m10: http://trac.webkit.org/changeset/72552
*/


Expand Down Expand Up @@ -37,23 +34,3 @@ window.matchMedia = window.matchMedia || (function(doc, undefined){
})(document);



/*
* EXAMPLE 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
}

0 comments on commit e72ca58

Please sign in to comment.