Skip to content

Instantly share code, notes, and snippets.

@barlas
Last active August 29, 2015 14:10
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 barlas/ba534410f46d4cda8ce7 to your computer and use it in GitHub Desktop.
Save barlas/ba534410f46d4cda8ce7 to your computer and use it in GitHub Desktop.
jQuery - Responsive return function triggering on document ready and window resize.
var windowW = $(window).width(),
windowH = $(window).height();
var resizeThread = 0;
function responsiveReturn() {
clearTimeout(resizeThread);
windowW = $(window).width();
windowH = $(window).height();
$('.window-size').css({'width': windowW +'px','height': windowH +'px'});
}
responsiveReturn();
$(window).resize(function() {
clearTimeout(resizeThread);
resizeThread = setTimeout(responsiveReturn,500);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment