13
13
* It will also attempt to prevent the native overflow scrolling on focus,
14
14
* which can cause layout issues such as pushing headers up and out of view.
15
15
*
16
- * The keyboard fixes work best in conjunction with the
16
+ * The keyboard fixes work best in conjunction with the
17
17
* [Ionic Keyboard Plugin](https://github.com/driftyco/ionic-plugins-keyboard),
18
18
* although it will perform reasonably well without. However, if you are using
19
19
* Cordova there is no reason not to use the plugin.
20
20
*
21
21
* ### Hide when keyboard shows
22
- *
22
+ *
23
23
* To hide an element when the keyboard is open, add the class `hide-on-keyboard-open`.
24
24
*
25
25
* ```html
30
30
* ----------
31
31
*
32
32
* ### Plugin Usage
33
- * Information on using the plugin can be found at
33
+ * Information on using the plugin can be found at
34
34
* [https://github.com/driftyco/ionic-plugins-keyboard](https://github.com/driftyco/ionic-plugins-keyboard).
35
35
*
36
- * ----------
36
+ * ----------
37
37
*
38
38
* ### Android Notes
39
- * - If your app is running in fullscreen, i.e. you have
39
+ * - If your app is running in fullscreen, i.e. you have
40
40
* `<preference name="Fullscreen" value="true" />` in your `config.xml` file
41
41
* you will need to set `ionic.Platform.isFullScreen = true` manually.
42
42
*
43
- * - You can configure the behavior of the web view when the keyboard shows by setting
43
+ * - You can configure the behavior of the web view when the keyboard shows by setting
44
44
* [android:windowSoftInputMode](http://developer.android.com/reference/android/R.attr.html#windowSoftInputMode)
45
45
* to either `adjustPan`, `adjustResize` or `adjustNothing` in your app's
46
46
* activity in `AndroidManifest.xml`. `adjustResize` is the recommended setting
57
57
* out of view on input focus, try setting `cordova.plugins.Keyboard.disableScroll(true)`.
58
58
* This does **not** disable scrolling in the Ionic scroll view, rather it
59
59
* disables the native overflow scrolling that happens automatically as a
60
- * result of focusing on inputs below the keyboard.
61
- *
60
+ * result of focusing on inputs below the keyboard.
61
+ *
62
62
*/
63
63
64
- var keyboardViewportHeight = window . innerHeight ;
64
+ var keyboardViewportHeight = getViewportHeight ( ) ;
65
65
var keyboardIsOpen ;
66
66
var keyboardActiveElement ;
67
67
var keyboardFocusOutTimer ;
@@ -205,8 +205,8 @@ function keyboardHide() {
205
205
}
206
206
207
207
function keyboardUpdateViewportHeight ( ) {
208
- if ( window . innerHeight > keyboardViewportHeight ) {
209
- keyboardViewportHeight = window . innerHeight ;
208
+ if ( getViewportHeight ( ) > keyboardViewportHeight ) {
209
+ keyboardViewportHeight = getViewportHeight ( ) ;
210
210
}
211
211
}
212
212
@@ -223,7 +223,7 @@ function keyboardPreventDefault(e) {
223
223
}
224
224
225
225
function keyboardOrientationChange ( ) {
226
- var updatedViewportHeight = window . innerHeight ;
226
+ var updatedViewportHeight = getViewportHeight ( ) ;
227
227
228
228
//too slow, have to wait for updated height
229
229
if ( updatedViewportHeight === keyboardViewportHeight ) {
@@ -234,7 +234,7 @@ function keyboardOrientationChange() {
234
234
clearInterval ( pollViewportHeight ) ;
235
235
}
236
236
237
- updatedViewportHeight = window . innerHeight ;
237
+ updatedViewportHeight = getViewportHeight ( ) ;
238
238
239
239
if ( updatedViewportHeight !== keyboardViewportHeight ) {
240
240
if ( updatedViewportHeight < keyboardViewportHeight ) {
@@ -267,10 +267,9 @@ function keyboardGetHeight() {
267
267
return 275 ;
268
268
}
269
269
//otherwise, wait for the screen to resize
270
- if ( window . innerHeight < keyboardViewportHeight ) {
271
- return keyboardViewportHeight - window . innerHeight ;
272
- }
273
- else {
270
+ if ( getViewportHeight ( ) < keyboardViewportHeight ) {
271
+ return keyboardViewportHeight - getViewportHeight ( ) ;
272
+ } else {
274
273
return 0 ;
275
274
}
276
275
}
@@ -293,6 +292,10 @@ function keyboardGetHeight() {
293
292
return 275 ;
294
293
}
295
294
295
+ function getViewportHeight ( ) {
296
+ return window . innerHeight || screen . height ;
297
+ }
298
+
296
299
function keyboardIsWithinScroll ( ele ) {
297
300
while ( ele ) {
298
301
if ( ele . classList . contains ( SCROLL_CONTAINER_CSS ) ) {
0 commit comments