From 1741fe95710556f30dc2442aaaae23e31dad4cc0 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 16 Aug 2018 13:34:05 -0700 Subject: [PATCH] Implement 'scrollEnabled' prop Summary: @public The content of `WKWebView` renders within a scrollview. In this diff, I'm introducing the prop `scrollEnabled` to allow developers to control whether scrolling is enabled within the scroll view, or not. Reviewed By: mmmulani Differential Revision: D6307001 fbshipit-source-id: 5a199c6c3b8535e45a5a3cb6041e822bb7af2362 --- React/Views/RCTWKWebView.h | 1 + React/Views/RCTWKWebView.m | 5 +++++ React/Views/RCTWKWebViewManager.m | 3 +++ 3 files changed, 9 insertions(+) diff --git a/React/Views/RCTWKWebView.h b/React/Views/RCTWKWebView.h index d094b72d4ddeeb..ca1d3ae1936ed7 100644 --- a/React/Views/RCTWKWebView.h +++ b/React/Views/RCTWKWebView.h @@ -20,6 +20,7 @@ @property (nonatomic, copy) NSDictionary *source; @property (nonatomic, assign) BOOL messagingEnabled; @property (nonatomic, copy) NSString *injectedJavaScript; +@property (nonatomic, assign) BOOL scrollEnabled; - (void)postMessage:(NSString *)message; diff --git a/React/Views/RCTWKWebView.m b/React/Views/RCTWKWebView.m index 2c9aef5e570ffd..63bab215932d7d 100644 --- a/React/Views/RCTWKWebView.m +++ b/React/Views/RCTWKWebView.m @@ -85,6 +85,11 @@ - (void)setSource:(NSDictionary *)source } } +- (void)setScrollEnabled:(BOOL)scrollEnabled +{ + _webView.scrollView.scrollEnabled = scrollEnabled; +} + - (void)postMessage:(NSString *)message { NSDictionary *eventInitDict = @{@"data": message}; diff --git a/React/Views/RCTWKWebViewManager.m b/React/Views/RCTWKWebViewManager.m index a2f8df4a5fbd30..5b71de0c7ac8b9 100644 --- a/React/Views/RCTWKWebViewManager.m +++ b/React/Views/RCTWKWebViewManager.m @@ -37,5 +37,8 @@ - (UIView *)view } RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL) +RCT_CUSTOM_VIEW_PROPERTY(scrollEnabled, BOOL, RCTWKWebView) { + view.scrollEnabled = json == nil ? true : [RCTConvert BOOL: json]; +} @end