Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

you deserve a readme, now dontcha.

  • Loading branch information...
commit e72ca583978db8f0abbbe282e182d29d72856d9e 1 parent 56af0aa
@paulirish authored
Showing with 33 additions and 23 deletions.
  1. +33 −0 README.md
  2. +0 −23 matchMedia.js
View
33 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/)
View
23 matchMedia.js
@@ -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
*/
@@ -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
-}
-
Please sign in to comment.
Something went wrong with that request. Please try again.