Skip to content

Instantly share code, notes, and snippets.

@michaelschofield
Created May 8, 2014 15:22
Show Gist options
  • Save michaelschofield/cd71b31bcda29c581246 to your computer and use it in GitHub Desktop.
Save michaelschofield/cd71b31bcda29c581246 to your computer and use it in GitHub Desktop.
Responsive Viewport
// There are probably more legit ways of doing this,
// but for my sparse use I sometimes use this.
// IE8 ployfill for GetComputed Style (for Responsive Script below)
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
if (re.test(prop)) {
prop = prop.replace(re, function () {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
}
return this;
}
}
// as the page loads, call these scripts
jQuery(document).ready(function($) {
var responsive_viewport = $(window).width();
if ( responsive_viewport >= 720 ) {
// Do something.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment