cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [4/6] cordova-plugins git commit: Instead of adding and removing observer when _shrinkView changes, check for _shrinkView in the method that is called. Always resize the webview if the keyboard is moving off screen. This covers the case when shrinkView i
Date Mon, 30 Mar 2015 14:12:58 GMT
Instead of adding and removing observer when _shrinkView changes, check for _shrinkView in
the method that is called. Always resize the webview if the keyboard is moving off screen.
This covers the case when shrinkView is disabled while the keyboard is visible. Only disable
the webview push up if shrinkView is enabled. Fix regression which broke disableScrollingInShrinkView.


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

Branch: refs/heads/master
Commit: 12911f63f99d184124508cd860a4d393bfb49484
Parents: 2823606
Author: Connor Pearson <cjp822@gmail.com>
Authored: Mon Jan 12 11:25:28 2015 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Mon Mar 30 10:12:23 2015 -0400

----------------------------------------------------------------------
 keyboard/src/ios/CDVKeyboard.m | 49 ++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/12911f63/keyboard/src/ios/CDVKeyboard.m
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m
index f03cefa..9d557a8 100644
--- a/keyboard/src/ios/CDVKeyboard.m
+++ b/keyboard/src/ios/CDVKeyboard.m
@@ -93,7 +93,13 @@
             [weakSelf.commandDelegate evalJs:@"Keyboard.fireOnHiding();"];
         }];
     
-    self.webView.scrollView.scrollEnabled = NO;
+    _shrinkViewKeyboardWillChangeFrameObserver = [nc addObserverForName:UIKeyboardWillChangeFrameNotification
+                                                                 object:nil
+                                                                  queue:[NSOperationQueue
mainQueue]
+                                                             usingBlock:^(NSNotification*
notification) {
+                                                                 [weakSelf performSelector:@selector(shrinkViewKeyboardWillChangeFrame:)
withObject:notification afterDelay:0];
+                                                             }];
+    
     self.webView.scrollView.delegate = self;
 }
 
@@ -158,31 +164,6 @@
 
 - (void)setShrinkView:(BOOL)ashrinkView
 {
-    NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
-    __weak CDVKeyboard* weakSelf = self;
-
-    if (ashrinkView == _shrinkView) {
-        return;
-    }
-
-    // No-op on iOS7.0.  It already resizes webview by default, and this plugin is causing
layout issues
-    // with fixed position elements.  We possibly should attempt to implement shringview
= false on iOS7.0.
-    // iOS 7.1+ behave the same way as iOS 6
-    if (!(NSFoundationVersionNumber == NSFoundationVersionNumber_iOS_7_0)) {
-        if (ashrinkView) {
-            [nc removeObserver:_shrinkViewKeyboardWillChangeFrameObserver];
-            _shrinkViewKeyboardWillChangeFrameObserver = [nc addObserverForName:UIKeyboardWillChangeFrameNotification
-                                                              object:nil
-                                                               queue:[NSOperationQueue mainQueue]
-                                                          usingBlock:^(NSNotification* notification)
{
-                    [weakSelf performSelector:@selector(shrinkViewKeyboardWillChangeFrame:)
withObject:notification afterDelay:0];
-                }];
-
-        } else {
-            [nc removeObserver:_shrinkViewKeyboardWillChangeFrameObserver];
-        }
-    }
-
     _shrinkView = ashrinkView;
 }
 
@@ -275,12 +256,22 @@
 
 - (void)shrinkViewKeyboardWillChangeFrame:(NSNotification*)notif
 {
+    // No-op on iOS7.0.  It already resizes webview by default, and this plugin is causing
layout issues
+    // with fixed position elements.  We possibly should attempt to implement shringview
= false on iOS7.0.
+    // iOS 7.1+ behave the same way as iOS 6
+    if (NSFoundationVersionNumber == NSFoundationVersionNumber_iOS_7_0){
+        return;
+    }
+    
+    self.webView.scrollView.scrollEnabled = YES;
+    
     CGRect screen = [self.viewController.view convertRect:[[UIScreen mainScreen] applicationFrame]
fromView:nil];
     CGRect keyboard = [self.viewController.view convertRect: ((NSValue*)notif.userInfo[@"UIKeyboardFrameEndUserInfoKey"]).CGRectValue
fromView: nil];
     CGRect keyboardIntersection = CGRectIntersection(screen, keyboard);
 
-    if(CGRectContainsRect(screen, keyboardIntersection)){
+    if(CGRectContainsRect(screen, keyboardIntersection) && _shrinkView){
         screen.size.height -= MIN(keyboardIntersection.size.height, keyboardIntersection.size.width);
+        self.webView.scrollView.scrollEnabled = !self.disableScrollingInShrinkView;
     }
     
     __weak CDVKeyboard* weakSelf = self;
@@ -340,6 +331,8 @@
 
 #pragma mark UIScrollViewDelegate
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
-    scrollView.bounds = self.webView.bounds;
+    if(_shrinkView){
+        scrollView.bounds = self.webView.bounds;
+    }
 }
 @end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message