【问题标题】:jquery mobile orientation detectionjquery移动方向检测
【发布时间】:2011-10-23 15:07:06
【问题描述】:

我正在使用 jquery-mobile,它似乎没有检测到横向设置。我正在使用什么:

iphone 模拟器版本 4.3 (238.2) 来自 Xcode 版本 4.1 Build 4B110 jQuery手机

我尝试在我的 mobile.js 中执行此操作

$(window).bind('orientationchange resize', function(event){
  alert(event.orientation)
})

转动模拟器只会一直给我一个提示,提示“纵向”,而它显然应该是横向的。

我在这里做错了吗?我还尝试在我们的 jammit 调用中使用媒体查询:

<%= include_stylesheet :landscape, :media => "all and (orientation: landscape)" %>

但无济于事。我在这里做错了吗?

顺便说一句,主要的错误是即使在转动 iphone 时,显示屏对我们来说仍然保持纵向宽度。

【问题讨论】:

标签: jquery-mobile ios-simulator orientation browser-detection jammit


【解决方案1】:

我在 jQM b2 js 文件中找到了这个:

JS:

alert('Orientation: ' + jQuery.event.special.orientationchange.orientation());

这是函数本身:

// Get the current page orientation. This method is exposed publicly, should it
// be needed, as jQuery.event.special.orientationchange.orientation()
$.event.special.orientationchange.orientation = get_orientation = function() {
    var elem = document.documentElement;
    return elem && elem.clientWidth / elem.clientHeight < 1.1 ? "portrait" : "landscape";
};

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-17
    相关资源
    最近更新 更多