Created
May 8, 2014 15:22
-
-
Save michaelschofield/cd71b31bcda29c581246 to your computer and use it in GitHub Desktop.
Responsive Viewport
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
// 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