Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mobile chrome fires resize event on scroll

I'm using the chrome mobile browser on galaxy s4, android 4.2.2 and for some reason every time I scroll the page down, it fires a resize event verified by the scaling of images from a jquery.cycle2 slideshow.

Any idea why this might be happening?

like image 680
KobeBryant Avatar asked Jun 26 '13 19:06

KobeBryant


2 Answers

That sounds strange, but I have seen it in other browsers. You can work around this like so.

var width = $(window).width(), height = $(window).height(); 

then in your resize event handler you can do.

if($(window).width() != width || $(window).height() != height){   //Do something } 

I don't know the scope of your functions and all that, but you should get the gist from this.

like image 157
CWitty Avatar answered Sep 25 '22 13:09

CWitty


Just for curiosity, I was trying to reproduce it and if I'm correct this is caused by the navigation chrome bar.

When you scroll down and chrome hides the browser navigation bar it produces a window resize, but this is correct, because after that we have a bigger window size due to the free space that the browser nav bar has left.

Related article: https://developers.google.com/web/updates/2016/12/url-bar-resizing

Consider CWitty answer to avoid this behavior.

like image 37
AlbertoFdzM Avatar answered Sep 23 '22 13:09

AlbertoFdzM