Skip to content

Instantly share code, notes, and snippets.

@jonnymaceachern
Created September 4, 2015 14:29
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonnymaceachern/9e2cea7e117f8142a00d to your computer and use it in GitHub Desktop.
Save jonnymaceachern/9e2cea7e117f8142a00d to your computer and use it in GitHub Desktop.
A resize event is triggered when a mobile browsers address bar drops down (when changing directions in a scroll). This will let you check for only width resizes. From http://stackoverflow.com/questions/10750603/jquery-detect-a-window-width-change-but-not-a-height-change
var width = $(window).width();
$(window).resize(function(){
if($(this).width() != width){
width = $(this).width();
console.log(width);
// your code
}
});
@webprom
Copy link

webprom commented May 30, 2021

great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment