From b2575a8ce364a34700388f9fcbbeec8449120388 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 28 Sep 2017 21:25:03 +1000 Subject: [PATCH] improve keyboard height detection --- .../javascripts/discourse/lib/safari-hacks.js.es6 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 index 0283e0e4200..86a60bd8353 100644 --- a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 +++ b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 @@ -17,22 +17,27 @@ function calcHeight() { let withoutKeyboard = window.innerHeight - 270; const min = 270; + // 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; + // portrait if (window.screen.height > window.screen.width) { - // iPhone SE + // iPhone SE, it is super small so just + // have a bit of crop if (window.screen.height === 568) { withoutKeyboard = 270; } // iPhone 6/7/8 if (window.screen.height === 667) { - withoutKeyboard = 295; + withoutKeyboard = smallViewport ? 295 : 325; } // iPhone 6/7/8 plus - if (window.innerHeight === 736) { - withoutKeyboard = 360; + if (window.screen.height === 736) { + withoutKeyboard = smallViewport ? 353 : 383; } // iPad can use innerHeight cause it renders nothing in the footer