Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
detect Iphone X
(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