滚动时的 JavaScript 调整大小事件 - 移动 [英] JavaScript resize event on scroll - mobile

查看:22
本文介绍了滚动时的 JavaScript 调整大小事件 - 移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为移动设备制作网站.我正在调整大小"事件有界于窗口,当移动设备转动时应该重新排列元素(纵向<->横向).在 iPhone 和三星 Galaxy SII 上,当我向下滚动页面时会触发该事件,这并不好.

I'm trying to make a website for mobile. I'm having the "resize" event bounded on window, which should rearrange elements when the mobile device is turning (portrait <-> landscape). On iPhone and Samsung Galaxy SII, the event is triggered when I'm scrolling down the page, and that's not good.

我该如何解决这个问题?

How can I fix this?

推荐答案

改用 onOrientationChange 事件和 window.orientation 属性.

Use the onOrientationChange event and the window.orientation property instead.

另见这个答案.

此处链接到测试页面.

这篇关于滚动时的 JavaScript 调整大小事件 - 移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆