Skip to content

Instantly share code, notes, and snippets.

@zearadoua
Created July 2, 2018 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zearadoua/90e6cd3b3ef05a1f08b6dd74a305ff8e to your computer and use it in GitHub Desktop.
Save zearadoua/90e6cd3b3ef05a1f08b6dd74a305ff8e to your computer and use it in GitHub Desktop.
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