cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject git commit: CB-6444 - Programmatic switch for position:fixed elements quirks after hiding kbd (closes #9)
Date Fri, 18 Apr 2014 22:12:37 GMT
Repository: cordova-plugins
Updated Branches:
  refs/heads/master c4ca22bf9 -> f543672d0


CB-6444 - Programmatic switch for position:fixed elements quirks after hiding kbd (closes
#9)


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/f543672d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/f543672d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/f543672d

Branch: refs/heads/master
Commit: f543672d09d7502e6c30867affe03cb2749505f6
Parents: c4ca22b
Author: Andrey Kurdyumov <kant2002@gmailc.om>
Authored: Fri Apr 18 11:18:00 2014 +0600
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Fri Apr 18 15:12:21 2014 -0700

----------------------------------------------------------------------
 keyboard/README.md             | 23 ++++++++++++++++++++++-
 keyboard/src/ios/CDVKeyboard.m |  8 ++++----
 keyboard/www/keyboard.js       | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/f543672d/keyboard/README.md
----------------------------------------------------------------------
diff --git a/keyboard/README.md b/keyboard/README.md
index 70abfdd..76d8426 100644
--- a/keyboard/README.md
+++ b/keyboard/README.md
@@ -118,7 +118,7 @@ Keyboard.isVisible
 Determine if the keyboard is visible.
 
     if (Keyboard.isVisible) {
-    	// do something
+        // do something
     }
 
 Description
@@ -132,6 +132,27 @@ Supported Platforms
 
 - iOS
 
+Keyboard.automaticScrollToTopOnHiding
+=================
+
+Specifies whenether content of page would be autoamtically scrolled to the top of the page
+when keyboard is hiding.
+
+    Keyboard.automaticScrollToTopOnHiding = true;
+
+Description
+-----------
+
+Set this to true if you need that page scroll to beginning when keyboard is hiding.
+This is allows to fix issue with elements declared with position: fixed,
+after keyboard is hiding.
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
 Keyboard.onshow
 =================
 

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/f543672d/keyboard/src/ios/CDVKeyboard.m
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m
index 2aa92b4..e2ce6ff 100644
--- a/keyboard/src/ios/CDVKeyboard.m
+++ b/keyboard/src/ios/CDVKeyboard.m
@@ -69,14 +69,14 @@
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = true;if (Keyboard.onshow)
Keyboard.onshow();"];
+            [weakSelf.commandDelegate evalJs:@"Keyboard.fireOnShow();"];
             weakSelf.keyboardIsVisible = YES;
         }];
     _keyboardHideObserver = [nc addObserverForName:UIKeyboardDidHideNotification
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = false;if (Keyboard.onhide)
Keyboard.onhide();"];
+            [weakSelf.commandDelegate evalJs:@"Keyboard.fireOnHide();"];
             weakSelf.keyboardIsVisible = NO;
         }];
 
@@ -84,13 +84,13 @@
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            [weakSelf.commandDelegate evalJs:@"if (Keyboard.onshowing) Keyboard.onshowing();"];
+            [weakSelf.commandDelegate evalJs:@"Keyboard.fireOnShowing();"];
         }];
     _keyboardWillHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
                                             object:nil
                                              queue:[NSOperationQueue mainQueue]
                                         usingBlock:^(NSNotification* notification) {
-            [weakSelf.commandDelegate evalJs:@"if (Keyboard.onhiding) Keyboard.onhiding();"];
+            [weakSelf.commandDelegate evalJs:@"Keyboard.fireOnHiding();"];
         }];
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/f543672d/keyboard/www/keyboard.js
----------------------------------------------------------------------
diff --git a/keyboard/www/keyboard.js b/keyboard/www/keyboard.js
index c810dce..b9bbae7 100644
--- a/keyboard/www/keyboard.js
+++ b/keyboard/www/keyboard.js
@@ -38,6 +38,38 @@ Keyboard.disableScrollingInShrinkView = function(disable) {
     exec(null, null, "Keyboard", "disableScrollingInShrinkView", [disable]);
 };
 
+Keyboard.fireOnShow = function() {
+    Keyboard.isVisible = true;
+    if (Keyboard.onshow) {
+        Keyboard.onshow();
+    }
+};
+Keyboard.fireOnHide = function() {
+    Keyboard.isVisible = false;
+    if (Keyboard.onhide) {
+        Keyboard.onhide();
+    }
+};
+Keyboard.fireOnHiding = function() {
+    // Automatic scroll to the top of the page
+    // to prevent quirks when using position:fixed elements
+    // inside WebKit browsers (iOS specifically).
+    // See CB-6444 for context.
+    if (Keyboard.automaticScrollToTopOnHiding) {
+        document.body.scrollLeft = 0;
+    }
+
+    if (Keyboard.onhiding) {
+        Keyboard.onhiding();
+    }
+};
+Keyboard.fireOnShowing = function() {
+    if (Keyboard.onshowing) {
+        Keyboard.onshowing();
+    }
+};
+
 Keyboard.isVisible = false;
+Keyboard.automaticScrollToTopOnHiding = false;
 
 module.exports = Keyboard;


Mime
View raw message