Skip to content

Commit

Permalink
Detect Vision Pro and disable magic window mode (fix #5559)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarcos committed Jul 29, 2024
1 parent 2c70bc2 commit 46f31ae
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utils/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ function isIpad (mockUserAgent, mockDevicePlatform, mockDeviceTouchPoints) {
}
module.exports.isIpad = isIpad;

/**
* Detect Apple Vision Pro devices.
*/
function isAppleVisionPro () {
// Safari for Apple Vision Pro presents itself as a desktop browser.
var isMacintosh = navigator.userAgent.includes('Macintosh');
// Discriminates between a "real" desktop browser and Safari for Vision Pro.
// Note: need to check for posible false positives on iPhones / iPads.
var hasFiveTouchPoints = navigator.maxTouchPoints === 5;
return isMacintosh && hasFiveTouchPoints;
}
module.exports.isAppleVisionPro = isAppleVisionPro;

function isIOS () {
return /iPad|iPhone|iPod/.test(window.navigator.platform);
}
Expand Down Expand Up @@ -176,7 +189,7 @@ module.exports.isFirefoxReality = isFirefoxReality;
* Detect browsers in Stand-Alone headsets
*/
function isMobileVR () {
return isOculusBrowser() || isFirefoxReality();
return isOculusBrowser() || isFirefoxReality() || isAppleVisionPro();
}
module.exports.isMobileVR = isMobileVR;

Expand Down

0 comments on commit 46f31ae

Please sign in to comment.