Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

javascript - 在HTML5中检测iPad Mini(Detect iPad Mini in HTML5)

Apple's iPad Mini is a smaller clone of the iPad 2 in more ways than we'd want.(Apple的iPad Mini是iPad 2的小型克隆,其方式比我们想要的更多。)

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.(在JavaScript中, window.navigator对象为Mini和iPad 2公开了相同的值。到目前为止我的测试检测差异并没有带来成功。)

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).(由于iPad Mini和iPad 2屏幕的像素相同但实际尺寸(英寸/厘米)不同,因此它们的PPI (每英寸像素数)不同。)

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.(对于提供友好用户界面的web应用和游戏,某些元素相对于用户的拇指或手指位置进行大小调整,因此,我们可能想要缩放某些图像或按钮以提供更好的用户体验。)

Things I have tried so far (including some pretty obvious approaches):(到目前为止我尝试过的事情(包括一些非常明显的方法):)

  • window.devicepixelratio
  • CSS element width in cm unit(CSS元素宽度,单位为cm)
  • CSS media queries (such as resolution and -webkit-device-pixel-ratio )(CSS媒体查询(例如resolution-webkit-device-pixel-ratio ))
  • SVG drawings in similar units(类似单位的SVG图纸)
  • 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)(在设定的时间内进行各种CSS webkit变换,并使用requestAnimFrame渲染帧进行计数(我希望能够检测出可测量的差异))

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.(我想评论人们投票反对检测iPad mini而不是2,因为苹果公司已经呃,这是一个统治它们的指导方针。) 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.(好的,这就是我的理由,为什么我觉得在这个世界上真的有意义的是知道一个人是在使用iPad mini还是2.并且我的理由是你喜欢的。)

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.(iPad mini不仅是一个小得多的设备(9.7英寸对7.9英寸),但它的外形允许不同的用途。)

The iPad 2 is usually held with two hands when gaming unless you're Chuck Norris .(除非你是查克诺里斯,否则iPad 2通常在游戏时用双手握住。) 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).(作为一名游戏设计师和开发者,我只想知道它是否是迷你游戏,所以如果我愿意,我可以选择为玩家提供不同的控制方案(例如在与一组玩家进行A / B测试之后)。)

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.(因此,恕我直言,这超出了粗略的手指/指南讨论,只是Apple和所有其他供应商应该做的事情:允许我们唯一地识别您的设备并思考不同而不是遵循指南。)

  ask by Martin Kool translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.(播放立体声音频文件并比较右声道和左声道音量较高时的加速度计响应 - iPad2有单声道扬声器,而iPad Mini有内置立体声扬声器。)

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(我没有iPad mini,所以我真的需要你的帮助)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...