jQuery – Oppress $(window).resize() in when scroll in mobile

I found that the $(window).resize() will be triggered when you scroll up/down the website on a mobile device. To prevent this happens, we could add a checking on the screen width.

var width = $(window).width();
$(window).resize(function(){
  if ($(window).width() != width) {
    // Only action on screen width change
    width = $(window).width();
  }
});

 

Done =)

Reference: StackOverflow – javascript resize event on scroll – mobile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s