From b204d2747d6b3af1973d6509dfaa78f6d2a7009b Mon Sep 17 00:00:00 2001
From: Lu Wang
Date: Wed, 26 Jul 2017 15:59:36 -0700
Subject: [PATCH] Add preference for native scroll to top
- As described in https://issues.apache.org/jira/browse/CB-13124
---
README.md | 4 ++++
src/ios/CDVStatusBar.m | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1c9301b..ccd8084 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,10 @@ Preferences
+- __StatusBarDefaultScrollToTop__ (boolean, defaults to false). On iOS 7, allows the Cordova WebView to use default scroll-to-top behavior. Defaults to false so you can listen to the "statusTap" event (described below) and customize the behavior instead.
+
+
+
### Android Quirks
The Android 5+ guidelines specify using a different color for the statusbar than your main app color (unlike the uniform statusbar color of many iOS 7+ apps), so you may want to set the statusbar color at runtime instead via `StatusBar.backgroundColorByHexString` or `StatusBar.backgroundColorByName`. One way to do that would be:
```js
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index 58fbc29..5cff277 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -137,8 +137,14 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
[self setStatusBarStyle:[self settingForKey:setting]];
}
+ setting = @"StatusBarDefaultScrollToTop";
+ if ([self settingForKey:setting]) {
+ self.webView.scrollView.scrollsToTop = [(NSNumber*)[self settingForKey:setting] boolValue];
+ } else {
+ self.webView.scrollView.scrollsToTop = NO;
+ }
+
// blank scroll view to intercept status bar taps
- self.webView.scrollView.scrollsToTop = NO;
UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds];
fakeScrollView.delegate = self;
fakeScrollView.scrollsToTop = YES;