Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/a16b08ff589b9d833600 to your computer and use it in GitHub Desktop.
Save wpscholar/a16b08ff589b9d833600 to your computer and use it in GitHub Desktop.
var mobile = 768;
var tablet = 1280;
var desktop = 1440;
/**
* Easily check if a breakpoint is active via JavaScript
*
* @param {string} breakpoint
* @returns {boolean}
*/
var isBreakpointActive = function (breakpoint) {
var isActive = false;
switch (breakpoint) {
case 'mobile':
isActive = (window.innerWidth <= mobile);
break;
case 'tablet':
isActive = (window.innerWidth > mobile && window.innerWidth <= tablet);
break;
case 'desktop':
isActive = (window.innerWidth > tablet);
break;
}
return isActive;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment