Skip to content

Commit

Permalink
Implement 'scrollEnabled' prop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RSNara authored and facebook-github-bot committed Aug 16, 2018
1 parent e5f95ab commit 1741fe9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions React/Views/RCTWKWebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions React/Views/RCTWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ - (void)setSource:(NSDictionary *)source
}
}

- (void)setScrollEnabled:(BOOL)scrollEnabled
{
_webView.scrollView.scrollEnabled = scrollEnabled;
}

- (void)postMessage:(NSString *)message
{
NSDictionary *eventInitDict = @{@"data": message};
Expand Down
3 changes: 3 additions & 0 deletions React/Views/RCTWKWebViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1741fe9

Please sign in to comment.