Created
November 4, 2014 18:05
-
-
Save tonylegrone/6d2bc57af4231fdb9e4c to your computer and use it in GitHub Desktop.
Quick little function for testing screensize against breakpoints. Requires jQuery.
This file contains 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 characters
/** | |
* Determines if screen size is within givin breakpoint. | |
* | |
* @param (string) op | |
* The breakpoint size to compare. Supported sizes are medium, large, xlarge | |
* and giant. | |
* | |
* @param (bool) mobileFirst | |
* Changes comparison from <= to >= if set to false. Deafults to true. | |
* | |
* @return (bool) | |
*/ | |
function breakPoint(op, mobileFirst) { | |
if (typeof(mobileFirst) === 'undefined') mobileFirst = true; | |
var breakPoints = { | |
medium: 480, | |
large: 640, | |
xlarge: 960, | |
giant: 1280, | |
}; | |
if (mobileFirst) { | |
return parseInt($(window).width()) >= breakPoints[op]; | |
} | |
else { | |
return parseInt($(window).width()) <= breakPoints[op]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment