mobile chrome fires resize event on scroll

前端 未结 7 1228
独厮守ぢ
独厮守ぢ 2020-11-30 23:20

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 im

7条回答
  •  旧时难觅i
    2020-12-01 00:09

    The question has already been answered, but since this question do not bring up the question of responsive sites I would like to add some information on that.

    I encountered this issue in Chrome on android when developing a responsive web site. When resizing the window I want to hide the menus (due to some design elements needing proper positioning) but the Chrome for android behaviour to trigger a resize event on scroll made that somewhat difficult..

    Switching to start using onOrientationChange was not an option since this is a responsive site, there is no orientation change on a desktop PC, but I still needed the code to work on both regular PC:s, tablets and smartphones.

    I could had started to do browser sniffing and such but I have so far been able to avoid that..

    I tried to implement the solution suggested by CWitty but since scrolling up or down in fact triggers a height-change that did not work either.

    I ended up adding a condition that only hides the menu when the width is changed, not when the height has changed. This works in my case since I only need to rewrite the menu when the width is changed.

提交回复
热议问题