Skip to content

Commit 74bc1ce

Browse files
committed
Merge pull request #2154 from karbon001/master
refactor(keyboard): add WP8 support for keyboard show
2 parents 77847f4 + 2cd4156 commit 74bc1ce

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

js/utils/keyboard.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ function keyboardInit() {
9595

9696
document.body.addEventListener('orientationchange', keyboardOrientationChange);
9797

98-
document.removeEventListener('touchstart', keyboardInit);
98+
if (window.navigator.msPointerEnabled) {
99+
document.removeEventListener("MSPointerDown", keyboardInit);
100+
}
101+
else {
102+
document.removeEventListener('touchstart', keyboardInit);
103+
}
99104
}
100105

101106
function keyboardNativeShow(e) {
@@ -176,7 +181,12 @@ function keyboardShow(element, elementTop, elementBottom, viewportHeight, keyboa
176181
// any showing part of the document that isn't within the scroll the user
177182
// could touchmove and cause some ugly changes to the app, so disable
178183
// any touchmove events while the keyboard is open using e.preventDefault()
179-
document.addEventListener('touchmove', keyboardPreventDefault, false);
184+
if (window.navigator.msPointerEnabled) {
185+
document.addEventListener("MSPointerMove", keyboardPreventDefault, false);
186+
}
187+
else {
188+
document.addEventListener('touchmove', keyboardPreventDefault, false);
189+
}
180190

181191
return details;
182192
}
@@ -200,7 +210,12 @@ function keyboardHide() {
200210
});
201211

202212
// the keyboard is gone now, remove the touchmove that disables native scroll
203-
document.removeEventListener('touchmove', keyboardPreventDefault);
213+
if (window.navigator.msPointerEnabled) {
214+
document.removeEventListener("MSPointerMove", keyboardPreventDefault);
215+
}
216+
else {
217+
document.removeEventListener('touchmove', keyboardPreventDefault);
218+
}
204219
document.removeEventListener('keydown', keyboardOnKeyDown);
205220
}
206221

@@ -319,6 +334,11 @@ ionic.Platform.ready(function() {
319334

320335
// only initialize the adjustments for the virtual keyboard
321336
// if a touchstart event happens
322-
document.addEventListener('touchstart', keyboardInit, false);
337+
if (window.navigator.msPointerEnabled) {
338+
document.addEventListener("MSPointerDown", keyboardInit, false);
339+
}
340+
else {
341+
document.addEventListener('touchstart', keyboardInit, false);
342+
}
323343
});
324344

0 commit comments

Comments
 (0)