Created
July 2, 2018 15:47
-
-
Save zearadoua/90e6cd3b3ef05a1f08b6dd74a305ff8e to your computer and use it in GitHub Desktop.
detect Iphone X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
"use strict"; | |
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; | |
// Get the device pixel ratio | |
var ratio = window.devicePixelRatio || 1; | |
// Define the users device screen dimensions | |
var screen = { | |
width : window.screen.width * ratio, | |
height : window.screen.height * ratio | |
}; | |
// iPhone X Detection | |
if (iOS && screen.width == 1125 && screen.height === 2436) { | |
$('body').addClass('iphoneX'); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment