mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e5f95aba9b
Summary:
@public
The content that loads inside `WKWebView` renders within a `ScrollView`. Suppose the user pulls the page down when its top edge hits the top edge of the web view. Then, one of two things can happen as the user continues to pull the page down:
1. We let the page be pulled past the top edge of the web view.
1. We fix the page's vertical offset to 0 so that it doesn't move past the top edge of the web view.
The property that controls this behaviour is `<WKWebView bounces={true|false}/>`. In this diff, I implement it.
Reviewed By: mmmulani
Differential Revision: D6306866
fbshipit-source-id: 7763df78676215c3dd0bd7a029497a6eca1873ab
42 lines
1.2 KiB
Objective-C
42 lines
1.2 KiB
Objective-C
#import "RCTWKWebViewManager.h"
|
|
|
|
#import "RCTUIManager.h"
|
|
#import "RCTWKWebView.h"
|
|
|
|
@implementation RCTWKWebViewManager
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
- (UIView *)view
|
|
{
|
|
return [RCTWKWebView new];
|
|
}
|
|
|
|
RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingStart, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingFinish, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
|
|
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
|
|
|
/**
|
|
* Expose methods to enable messaging the webview.
|
|
*/
|
|
RCT_EXPORT_VIEW_PROPERTY(messagingEnabled, BOOL)
|
|
RCT_EXPORT_VIEW_PROPERTY(onMessage, RCTDirectEventBlock)
|
|
|
|
RCT_EXPORT_METHOD(postMessage:(nonnull NSNumber *)reactTag message:(NSString *)message)
|
|
{
|
|
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWKWebView *> *viewRegistry) {
|
|
RCTWKWebView *view = viewRegistry[reactTag];
|
|
if (![view isKindOfClass:[RCTWKWebView class]]) {
|
|
RCTLogError(@"Invalid view returned from registry, expecting RCTWebView, got: %@", view);
|
|
} else {
|
|
[view postMessage:message];
|
|
}
|
|
}];
|
|
}
|
|
|
|
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
|
|
|
|
@end
|