ionic-team / cordova-plugin-ionic-keyboard

Keyboard Plugin for Cordova
Other
193 stars 178 forks source link

Keyboard height is incorrect on iPhone X #62

Closed kotromeo closed 5 years ago

kotromeo commented 5 years ago

Using event keyboardDidShow, getting keyboard height and it's about 379 but should be 760

matejkramny commented 5 years ago

you're not accounting for pixel density of ~2 so it works out to around 760. I'm having the same issue, going to post a PR fixing this. The keyboard height is correct. What it's not doing is accounting for the 'safe' area inset of the bottom bar.

https://medium.com/rosberryapps/ios-safe-area-ca10e919526f

kotromeo commented 5 years ago

you're not accounting for pixel density of ~2 so it works out to around 760. I'm having the same issue, going to post a PR fixing this. The keyboard height is correct. What it's not doing is accounting for the 'safe' area inset of the bottom bar.

https://medium.com/rosberryapps/ios-safe-area-ca10e919526f

So problem on my side to determine 2x density or this problem on plugin side ?

jcesarmobile commented 5 years ago

The plugin return the size in points, and the size is correct. For iPhone X, 1 point = 3 pixels, that means its screen is 2436x1125 pixels, but 812x375 points.

If you have a viewport like this <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> then your css values will also be considered as points, meaning your app resolution is really 812x375 pixels, not 2436x1125.

If for some reason you need the real pixels, you'll have to multiply the returned keyboard size by devicePixelRatio (which is 3 for iPhone X).

Not sure where you get that size should be 760