From e2a8e13c077ee7c535686cc94de8b154ecd78b00 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Mon, 30 Apr 2018 15:39:31 +0700 Subject: [PATCH] Created an integrated rotation testing page. Needs more work. --- web/source/kmwnative.ts | 48 +++++++----- web/test.html | 44 ----------- web/testing/index.html | 1 + web/testing/rotation-events/index.html | 101 +++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 64 deletions(-) delete mode 100644 web/test.html create mode 100644 web/testing/rotation-events/index.html diff --git a/web/source/kmwnative.ts b/web/source/kmwnative.ts index a9e4bb2ce1..c6784983d9 100644 --- a/web/source/kmwnative.ts +++ b/web/source/kmwnative.ts @@ -465,30 +465,38 @@ if(!window['keyman']['initialized']) { ); } } + + // Placing the rotation handler in two separate functions allows us to stub the functions for + // debugging/event-logging. + keymanweb.innerRotationHandler = function() { + keymanweb.alignInputs(true); + osk.hideLanguageList(); + osk._Load(); + if(osk.wasVisible) { + osk._Show(); + } + + // clear timeout variable, if it exists. + } + + // A general handler for rotation events on touch-enabled devices. + keymanweb.rotationHandler = function() { + osk.wasVisible = osk.isVisible(); + osk.hideNow(); + + // At least on simulators, it seems we can reach a minor race condition on screen-size updates without a timeout. + //window.setTimeout(function() { + keymanweb.innerRotationHandler(); + //}, 500); + } /** * Use rotation events to adjust OSK and input element positions and scaling as necessary */ keymanweb.handleRotationEvents=function() { - // General handler for rotation events. - var rotationHandler: () => void = function() { - osk.wasVisible = osk.isVisible(); - osk.hideNow(); - - // At least on simulators, it seems we can reach a minor race condition on screen-size updates without a timeout. - //window.setTimeout(function() { - keymanweb.alignInputs(true); - osk.hideLanguageList(); - osk._Load(); - if(osk.wasVisible) { - osk._Show(); - } - //}, 500); - }; - - if(device.OS == 'iOS') { - util.attachDOMEvent(window, 'orientationchange', rotationHandler); - util.attachDOMEvent(window, 'resize', rotationHandler); + if(device.OS == 'iOS') { + util.attachDOMEvent(window, 'orientationchange', keymanweb.rotationHandler); + util.attachDOMEvent(window, 'resize', keymanweb.rotationHandler); } // Also manage viewport rescaling after rotation on Android @@ -500,7 +508,7 @@ if(!window['keyman']['initialized']) { util.attachDOMEvent(screen,'mozorientationchange',osk.hideNow); // Then align inputs and redisplay the OSK on resize event following rotation - util.attachDOMEvent(window, 'resize', rotationHandler); + util.attachDOMEvent(window, 'resize', keymanweb.rotationHandler); } //TODO: may be able to recognize start of rotation using accelerometer call... diff --git a/web/test.html b/web/test.html deleted file mode 100644 index e8e6542c57..0000000000 --- a/web/test.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/web/testing/index.html b/web/testing/index.html index 0f3941b1e9..817c53feb9 100644 --- a/web/testing/index.html +++ b/web/testing/index.html @@ -38,6 +38,7 @@

Uxxxx code testing

Test page for interactions between setActiveKeyboard and the toolbar UI.

Test page for IFrame connectivity and class prototype management.

+

Test page for evaluating issues with mobile device rotation events.

Return to main index. diff --git a/web/testing/rotation-events/index.html b/web/testing/rotation-events/index.html new file mode 100644 index 0000000000..484f371566 --- /dev/null +++ b/web/testing/rotation-events/index.html @@ -0,0 +1,101 @@ + + + + + + KeymanWeb Sample Page - Unminified Source + + + + + + + + + + + + + + + + + + + +

+ + + +

Return to main index. + + \ No newline at end of file