Merge pull request #83 from lunaru/master

CB-13124: Add option for native scroll-to-top on WebView
This commit is contained in:
jcesarmobile 2017-11-02 23:54:26 +01:00 committed by GitHub
commit 4642be07a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -65,6 +65,10 @@ Preferences
<preference name="StatusBarStyle" value="lightcontent" />
- __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.
<preference name="StatusBarDefaultScrollToTop" value="false" />
### 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

View File

@ -138,8 +138,14 @@ static const void *kStatusBarStyle = &kStatusBarStyle;
[self setStatusBarStyle:[self settingForKey:setting]];
}
// blank scroll view to intercept status bar taps
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
UIScrollView *fakeScrollView = [[UIScrollView alloc] initWithFrame:UIScreen.mainScreen.bounds];
fakeScrollView.delegate = self;
fakeScrollView.scrollsToTop = YES;