fix(WKWebview Scroll): Don't allow the scrollView to scroll when scrollEnabled={false}. (#158)

* Don't allow the scrollview to scroll the WebView body.

* Readme comment

* Remove duplicate protocol def
This commit is contained in:
Chet Corcos
2019-02-28 22:01:42 +01:00
committed by Thibault Malbranche
parent bef06e63f7
commit 0e6e92a7f1
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -446,7 +446,7 @@ With the [new WebKit](Reference.md#usewebkit) implementation, we have three new
### `scrollEnabled`
Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`.
Boolean value that determines whether scrolling is enabled in the `WebView`. The default value is `true`. Setting this to `false` will prevent the webview from moving the document body when the keyboard appears over an input.
| Type | Required | Platform |
| ---- | -------- | -------- |
+13
View File
@@ -341,6 +341,19 @@ static NSURLCredential* clientAuthenticationCredential;
{
_scrollEnabled = scrollEnabled;
_webView.scrollView.scrollEnabled = scrollEnabled;
// Override the scrollView delegate to prevent scrolling.
if (!scrollEnabled) {
_webView.scrollView.delegate = self;
} else {
_webView.scrollView.delegate = _webView;
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// Don't allow scrolling the scrollView.
scrollView.bounds = _webView.bounds;
}
- (void)setShowsHorizontalScrollIndicator:(BOOL)showsHorizontalScrollIndicator