Last active
August 29, 2015 14:19
-
-
Save Morasta/f55e2dbafb215c310b61 to your computer and use it in GitHub Desktop.
Script to print current Bootstrap viewport breakpoint size
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 characters
<script src="https://rawgit.com/maciej-gurban/responsive-bootstrap-toolkit/master/js/bootstrap-toolkit.min.js"></script> | |
<script> | |
function getCurrentVP(viewport) { | |
var currentViewport= 'n/a'; | |
if( viewport.is('xs') ) { | |
currentViewport = 'xs'; | |
} | |
else if( viewport.is('sm') ) { | |
currentViewport = 'sm'; | |
} | |
else if( viewport.is('md') ) { | |
currentViewport = 'md'; | |
} | |
else if( viewport.is('lg') ) { | |
currentViewport = 'lg'; | |
} | |
return currentViewport; | |
} | |
(function($, viewport){ | |
currentViewport = ""; | |
// Initial load handling | |
$(document).ready(function() { | |
currentViewport = getCurrentVP(viewport); | |
console.log('current viewport: '+currentViewport); | |
}); | |
// Window resize handling | |
$(window).bind('resize', function() { | |
viewport.changed(function(){ | |
var newVp = getCurrentVP(viewport); | |
if (currentViewport != newVp) { | |
currentViewport = newVp; | |
console.log("viewport changed to: "+currentViewport); | |
} | |
}); | |
}); | |
})(jQuery, ResponsiveBootstrapToolkit); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment