在HTML5中检测iPad Mini [英] Detect iPad Mini in HTML5

查看:105
本文介绍了在HTML5中检测iPad Mini的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

苹果的iPad Mini是iPad 2的一个更小的克隆,其方式比我们想要的更多。在JavaScript中, window.navigator 对象公开了Mini和iPad 2的相同值。到目前为止,我检测差异的测试并未取得成功。



为什么这很重要?

由于iPad Mini和iPad 2屏幕的像素相同,但实际尺寸(英寸/厘米)不同,因此它们在PPI (每英寸像素数)。



对于网页应用程序和游戏提供友好的用户界面,确定元素的尺寸相对于用户的拇指或手指位置进行了调整,因此,我们可能想要缩放某些图像或按钮以提供更好的用户体验。



事情I (包括一些非常明显的方法):


  • window.devicepixelratio

  • 以cm为单位的CSS元素宽度
  • CSS媒体查询(例如 resolution -webkit-device-pixel-ratio

  • 类似单位的SVG图纸

  • 一些CSS webkit转换一段时间并用 requestAnimFrame 计算渲染帧(我希望能够检测到可衡量的差异)



我很新鲜。你呢?

更新
感谢迄今的回应。我想评论一下投票反对检测iPad mini和2的人,因为苹果公司有一个呃,一个指导方针来统治他们。好的,这是我的推理,为什么我觉得在世界上知道一个人是否使用iPad mini或2是真的很有意义。并且按照我的推理你喜欢什么。



iPad mini不仅是一个更小的设备(9.7英寸与7.9英寸),但其外形允许不同的用途。除非你是 Chuck Norris ,否则在游戏中通常会用两只手握住iPad 2。迷你比较小,但它也轻得多,并且允许您单手拿着游戏并使用另一个来轻扫或轻敲或不使用游戏。作为一名游戏设计师和开发人员,我只想了解是否为迷你游戏,以便我可以选择为玩家提供不同的控制策略(例如,在A / B测试之后一群球员)。


为什么?嗯,大多数用户倾向于使用默认设置,因此在播放器加载完成时忽略了一个虚拟的拇指按钮并在屏幕上放置了其他基于Tap的控件(这里只给出一个任意示例)游戏的第一次是我和其他游戏设计师所喜欢的能够做的。

所以,恕我直言,这超越了厚厚的手指/指导方针讨论,只是Apple和所有其他供应商应该做的事情:允许我们唯一标识您的设备,认为不同,而不是遵循准则。当音量在右声道和左声道高时,播放立体声音频文件并比较加速度计响应 - iPad2有单声道而iPad Mini则内置了立体声扬声器。


需要您的帮助来收集数据,请访问此页面,并帮助我为这个疯狂的想法收集数据。我没有iPad mini,所以我真的需要你的帮助


Apple's iPad Mini is a smaller clone of the iPad 2 in more ways than we'd want. In JavaScript, the window.navigator object exposes the same values for the Mini and iPad 2. My tests so far to detect the difference have not lead to success.

Why is this important?

As the iPad Mini and iPad 2 screens are identical in pixels but vary in actual size (inches / centimeters), they vary in PPI (pixels per inch).

For web applications and games to offer a friendly user interface, certain elements are adjusted in size relative to a user's thumb or finger position, thus, we may want to scale certain images or buttons to provide for that better user experience.

Things I have tried so far (including some pretty obvious approaches):

  • window.devicepixelratio
  • CSS element width in cm unit
  • CSS media queries (such as resolution and -webkit-device-pixel-ratio)
  • SVG drawings in similar units
  • Doing all sorts of CSS webkit transforms for a set time and counting rendered frames with requestAnimFrame (I was hoping to detect a measurable difference)

I'm fresh out of ideas. How about you?

Update Thanks for the responses so far. I would like to comment on people voting against detecting iPad mini versus 2 as Apple has uhm, one guideline to rule them all. Okay, here's my reasoning why I feel it really makes all sense in the world to know if a person is using an iPad mini or a 2. And do with my reasoning what you like.

The iPad mini is not only a much smaller device (9.7 inch versus 7.9 inch), but its form factor allows for a different usage. The iPad 2 is usually held with two hands when gaming unless you're Chuck Norris. The mini is smaller, but it is also much lighter and allows for gameplay where you hold it in one hand and use another to swipe or tap or whatnot. As a game designer and developer myself, I'd just like to know if it's a mini so I can choose to provide the player with a different controlscheme if I want (for instance after A/B testing with a group of players).

Why? Well, it's a proven fact that the majority of users tend to go with the default settings, so leaving out a virtual thumbstick and putting some other tap-based control on the screen (just giving an arbitrary example here) when the player loads up the game for the first time is what I, and probably other game designers, would love to be able to do.

So IMHO this goes beyond the thick fingers / guidelines discussions and is just something Apple and all other vendors ought to do: allow us to uniquely identify your device and think different instead of following guidelines.

解决方案

Play a stereo audio file and compare the accelerometer response when volume is high on the right channel and on the left channel - iPad2 had mono speakers whereas iPad Mini has built-in stereo speakers.

Need your help to gather the data please visit this page and help me collect data for this crazy idea. I don't have an iPad mini so I really need your help

这篇关于在HTML5中检测iPad Mini的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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