Last active
December 13, 2015 19:28
-
-
Save brianlmoon/4962688 to your computer and use it in GitHub Desktop.
Revisions
-
brianlmoon revised this gist
Feb 15, 2013 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,13 +18,7 @@ function getWindowMediaWidth() { ]; for(var x = 0; x<values.length; x++){ if (window.matchMedia("(min-width: " + values[x] + "px) and (max-width: " + values[x] + "px)").matches) { return values[x]; } } -
brianlmoon renamed this gist
Feb 15, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
brianlmoon created this gist
Feb 15, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ function getWindowMediaWidth() { if(!window.matchMedia){ // it should be this, so return it when we can't // figure it out. Of course, it does not do a lot // of good if the browser does not support media // queries. return document.body.clientWidth; } // it should be one of these values starting with the // first one that makes the most sense var values = [ document.body.clientWidth, // Chrome returns this window.innerWidth, // Firefox returns this because window.outerWidth, // this is the same as above on browsers with no window borders screen.width // last ditch effort here ]; for(var x = 0; x<values.length; x++){ console.log(x + ": " + values[x]); } for(var x = 0; x<values.length; x++){ if (window.matchMedia("(min-width: " + values[x] + "px) and (max-width: " + values[x] + "px)").matches) { console.log("Matched " + x + ": " + values[x]); return values[x]; } } }