From 05dd97ffe076ef71e1e6283566506ef6d3812fa0 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 29 Sep 2017 11:48:52 +1000 Subject: [PATCH] correct iPad sizing --- .../javascripts/discourse/lib/safari-hacks.js.es6 | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 index 86a60bd8353..43c70615f01 100644 --- a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 +++ b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 @@ -19,10 +19,10 @@ function calcHeight() { // iPhone shrinks header and removes footer controls ( back / forward nav ) // at 39px we are at the largest viewport - const smallViewport = (window.screen.height - window.innerHeight) > 40; + const portrait = window.innerHeight > window.innerWidth; + const smallViewport = ((portrait ? window.screen.height : window.screen.width) - window.innerHeight) > 40; - // portrait - if (window.screen.height > window.screen.width) { + if (portrait) { // iPhone SE, it is super small so just // have a bit of crop @@ -39,24 +39,22 @@ function calcHeight() { if (window.screen.height === 736) { withoutKeyboard = smallViewport ? 353 : 383; } - // iPad can use innerHeight cause it renders nothing in the footer if (window.innerHeight > 920) { withoutKeyboard -= 45; } } else { + // landscape - // // iPad, we have a bigger keyboard - if (window.innerWidth > window.innerHeight && window.innerHeight > 665) { + if (window.innerHeight > 665) { withoutKeyboard -= 128; } } // iPad portrait also has a bigger keyboard - return Math.max(withoutKeyboard, min); }