Skip to content

Instantly share code, notes, and snippets.

@dmssk
Last active July 23, 2019 11:32
Show Gist options
  • Save dmssk/ee0267d0618ae695bf9698ea1ecb5873 to your computer and use it in GitHub Desktop.
Save dmssk/ee0267d0618ae695bf9698ea1ecb5873 to your computer and use it in GitHub Desktop.
if(navigator.userAgent.match(/iPad/i)) {
const ORIGINAL_WIDTH = 1024;
const ORIGINAL_HEIGHT = 768;
// screen.height === actual device width
// screen.width === actual device height
const w = screen.height;
const h = screen.width;
const BROWSER_TABS = h - window.innerHeight;
const WIDTH_SCALE = Math.round(w / (ORIGINAL_WIDTH / 100)) / 100;
const HEIGHT_SCALE = Math.round((h - BROWSER_TABS) / (ORIGINAL_HEIGHT / 100)) / 100;
document.querySelector("body").style.transform = `scale(${WIDTH_SCALE}, ${HEIGHT_SCALE})`;
document.querySelector("body").style.transformOrigin = `top left`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment