mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Improve reliability of detecting small devices when loading Differential changesets
Summary: Ref T10229. Fixes T9969. We make a decision about 1up vs 2up pretty early, and sometimes the viewport size reads as larger than the device, so we incorrectly select 2up when the proper setting would be 1up. Test Plan: I can reproduce this by, e.g., reloading a lot on an iPhone 4s in iOS Simulator running iOS 9.2. Sometimes it picks 2-up. I added logging to show that the viewport dimension read was the issue. After this change, it always selects 1-up (`window.screen.availWidth` is defined and sensible on the device). Reviewers: chad Reviewed By: chad Maniphest Tasks: T9969, T10229 Differential Revision: https://secure.phabricator.com/D15135
This commit is contained in:
parent
e4372e1276
commit
dbf1d0d721
1 changed files with 13 additions and 0 deletions
|
@ -26,6 +26,19 @@ JX.install('Device', {
|
|||
var v = JX.Vector.getViewport();
|
||||
var self = JX.Device;
|
||||
|
||||
// Even when we emit a '<meta name="viewport" ... />' tag which tells
|
||||
// devices to fit the conent to the screen width, we'll sometimes measure
|
||||
// a viewport dimension which is larger than the available screen width,
|
||||
// particularly if we check too early.
|
||||
|
||||
// If the device provides a screen width and the screen width is smaller
|
||||
// than the viewport width, use the screen width.
|
||||
|
||||
var screen_width = (window.screen && window.screen.availWidth);
|
||||
if (screen_width) {
|
||||
v.x = Math.min(v.x, screen_width);
|
||||
}
|
||||
|
||||
var device = 'desktop';
|
||||
if (v.x <= self._tabletBreakpoint) {
|
||||
device = 'tablet';
|
||||
|
|
Loading…
Reference in a new issue