You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/02/22 19:38:09 UTC

[GitHub] jaandrle commented on issue #417: Keyboard Dismissal Leaves Viewport Shifted in iOS 12 / XCode 10

jaandrle commented on issue #417: Keyboard Dismissal Leaves Viewport Shifted in iOS 12 / XCode 10
URL: https://github.com/apache/cordova-ios/issues/417#issuecomment-466520675
 
 
   Another way:
   in HTML:
   ```HTML
   <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"/>
   ```
   Somewhere 'deviceready'/'DOMContentLoaded' in JS (depends on `cordova-plugin-keyboard`):
   ```JavaScript
   (function ios12NotchFix(is_ios, keyboard_plugin_exists){
       if(!is_ios || device.model.indexOf("iPhone")===-1) return false;
       if(!keyboard_plugin_exists) throw new Error("This fix depends on 'cordova-plugin-keyboard'!");
       const iphone_number= Number(device.model.replace("iPhone", "").replace(",","."));
       const /* viewport metatag */
           viewport_el= document.getElementsByName("viewport")[0],
           default_content= "user-scalable=no, width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1";
       if(iphone_number>=10.6||iphone_number===10.3){ /* devices with notch: X, XR, ... */
           setCover();
           window.addEventListener('keyboardWillShow', setFix);
           window.addEventListener('keyboardWillHide', setCover);
       }
       function setCover(){ viewport_el.content= default_content+", viewport-fit=cover"; }
       function setFix(){ viewport_el.content= default_content; }
   })(device.platform==="iOS", typeof Keyboard !== "undefined");

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org