CB-8839 - WKWebView ignores DisallowOverscroll preference

Project: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/commit/fa97a17a
Tree: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/tree/fa97a17a
Diff: 
http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/diff/fa97a17a

Branch: refs/heads/master
Commit: fa97a17abe14c8e1012910cb9250ec0c2e9d61e1
Parents: cc2bdfb
Author: Shazron Abdullah <[email protected]>
Authored: Sun Apr 19 00:51:49 2015 -0700
Committer: Shazron Abdullah <[email protected]>
Committed: Sun Apr 19 00:51:49 2015 -0700

----------------------------------------------------------------------
 src/ios/CDVWKWebViewEngine.m | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-wkwebview-engine/blob/fa97a17a/src/ios/CDVWKWebViewEngine.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVWKWebViewEngine.m b/src/ios/CDVWKWebViewEngine.m
index 65b1bd5..d7c2d78 100644
--- a/src/ios/CDVWKWebViewEngine.m
+++ b/src/ios/CDVWKWebViewEngine.m
@@ -129,6 +129,22 @@
      wkWebView.configuration.preferences.javaScriptEnabled = [settings 
cordovaBoolSettingForKey:@"JavaScriptEnabled" default:YES];
      wkWebView.configuration.preferences.javaScriptCanOpenWindowsAutomatically 
= [settings cordovaBoolSettingForKey:@"JavaScriptCanOpenWindowsAutomatically" 
default:NO];
      */
+    
+    // By default, DisallowOverscroll is false (thus bounce is allowed)
+    BOOL bounceAllowed = !([settings 
cordovaBoolSettingForKey:@"DisallowOverscroll" defaultValue:NO]);
+    
+    // prevent webView from bouncing
+    if (!bounceAllowed) {
+        if ([wkWebView respondsToSelector:@selector(scrollView)]) {
+            ((UIScrollView*)[wkWebView scrollView]).bounces = NO;
+        } else {
+            for (id subview in wkWebView.subviews) {
+                if ([[subview class] isSubclassOfClass:[UIScrollView class]]) {
+                    ((UIScrollView*)subview).bounces = NO;
+                }
+            }
+        }
+    }
 }
 
 - (void)updateWithInfo:(NSDictionary*)info


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to