mirror of
https://github.com/status-im/react-native-webview.git
synced 2026-08-31 19:51:10 +00:00
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:
committed by
Thibault Malbranche
parent
bef06e63f7
commit
0e6e92a7f1
+1
-1
@@ -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 |
|
||||
| ---- | -------- | -------- |
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user