Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect window.innerHeight when using WKWebView and shrinkView #32

Closed
cjpearson opened this issue Aug 3, 2016 · 1 comment
Closed

Comments

@cjpearson
Copy link
Owner

Related to: https://bugs.webkit.org/show_bug.cgi?id=150634

On iOS 8 and 9, WKWebView subtracts the keyboard height from window.innerHeight. Since we already shrink the frame when shrinkView is enabled, this is not necessary and causes window.innerHeight to be too small.

@katamshut
Copy link

katamshut commented Oct 30, 2017

I am facing a problem on iOS. Not sure if this is releated to the plugin since it is not sure if the UIWebView fire the resize event when keyboar gets hidden (https://www.quirksmode.org/dom/events/resize_mobile.html).

I tested to listen to the resize event when the keyboard hides. It looks like it is quite random if the resize event is fired or not. The window.innerHeight gets adjusted everytime (just according to the fix #32 here).

I finally use this "selfmade" window innerHeight listerner to ensure my resize work to be done:

window.addEventListener('keyboardHeightWillChange', function () {
function onElementHeightChange(elm, callback){
var lastHeight = elm.innerHeight, newHeight;
(function run(){
newHeight = elm.innerHeight;
if( lastHeight != newHeight ){
callback();
clearTimeout(elm.onElementHeightChangeTimer);
return;
}
lastHeight = newHeight;

  if( elm.onElementHeightChangeTimer )
    clearTimeout(elm.onElementHeightChangeTimer);

  elm.onElementHeightChangeTimer = setTimeout(run, 1);
})();

}
onElementHeightChange(window, function(){
//do something
});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants