Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apple/RNCWebView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
REMAP_WEBVIEW_PROP(showsHorizontalScrollIndicator)
REMAP_WEBVIEW_PROP(showsVerticalScrollIndicator)
REMAP_WEBVIEW_PROP(forceLightScrollIndicators)
REMAP_WEBVIEW_PROP(scrollsToTop)
REMAP_WEBVIEW_PROP(keyboardDisplayRequiresUserAction)

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 /* __IPHONE_13_0 */
Expand Down
1 change: 1 addition & 0 deletions apple/RNCWebViewImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
@property (nonatomic, assign) BOOL forceLightScrollIndicators;
@property (nonatomic, assign) BOOL scrollsToTop;
@property (nonatomic, assign) BOOL directionalLockEnabled;
@property (nonatomic, assign) BOOL ignoreSilentHardwareSwitch;
@property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL;
Expand Down
8 changes: 8 additions & 0 deletions apple/RNCWebViewImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ - (instancetype)initWithFrame:(CGRect)frame
_showsHorizontalScrollIndicator = YES;
_showsVerticalScrollIndicator = YES;
_forceLightScrollIndicators = NO;
_scrollsToTop = YES;
_directionalLockEnabled = YES;
_automaticallyAdjustContentInsets = YES;
_autoManageStatusBarEnabled = YES;
Expand Down Expand Up @@ -504,6 +505,7 @@ - (void)didMoveToWindow
else{
_webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleDefault;
}
_webView.scrollView.scrollsToTop = _scrollsToTop;
_webView.scrollView.directionalLockEnabled = _directionalLockEnabled;
#endif // !TARGET_OS_OSX
_webView.allowsLinkPreview = _allowsLinkPreview;
Expand Down Expand Up @@ -1043,6 +1045,12 @@ - (void)setForceLightScrollIndicators:(BOOL)forceLightScrollIndicators
_webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleDefault;
}
}

- (void)setScrollsToTop:(BOOL)scrollsToTop
{
_scrollsToTop = scrollsToTop;
_webView.scrollView.scrollsToTop = scrollsToTop;
}
#endif // !TARGET_OS_OSX

- (void)postMessage:(NSString *)message
Expand Down
4 changes: 4 additions & 0 deletions apple/RNCWebViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ - (RNCView *)view
view.forceLightScrollIndicators = json == nil ? true : [RCTConvert BOOL: json];
}

RCT_CUSTOM_VIEW_PROPERTY(scrollsToTop, BOOL, RNCWebViewImpl) {
view.scrollsToTop = json == nil ? true : [RCTConvert BOOL: json];
}

RCT_CUSTOM_VIEW_PROPERTY(keyboardDisplayRequiresUserAction, BOOL, RNCWebViewImpl) {
view.keyboardDisplayRequiresUserAction = json == nil ? true : [RCTConvert BOOL: json];
}
Expand Down
4 changes: 3 additions & 1 deletion lib/RNCWebViewNativeComponent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ export interface NativeProps extends ViewProps {
onShouldStartLoadWithRequest: DirectEventHandler<ShouldStartLoadRequestEvent>;
showsHorizontalScrollIndicator?: boolean;
showsVerticalScrollIndicator?: boolean;
forceLightScrollIndicators?: boolean;
scrollsToTop?: boolean;
newSource: Readonly<{
uri?: string;
method?: string;
Expand All @@ -235,7 +237,7 @@ export interface NativeCommands {
clearFormData: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
clearCache: (viewRef: React.ElementRef<HostComponent<NativeProps>>, includeDiskFiles: boolean) => void;
clearHistory: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
setTintColor: (viewRef: React.ElementRef<HostComponent<NativeProps>>, red: number, blue: number, green: number, alpha: number) => void;
setTintColor: (viewRef: React.ElementRef<HostComponent<NativeProps>>, red: Double, blue: Double, green: Double, alpha: Double) => void;
}
export declare const Commands: NativeCommands;
declare const _default: HostComponent<NativeProps>;
Expand Down
2 changes: 1 addition & 1 deletion lib/RNCWebViewNativeComponent.d.ts.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion lib/WebViewTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export interface CommonNativeWebViewProps extends ViewProps {
onShouldStartLoadWithRequest: (event: ShouldStartLoadRequestEvent) => void;
showsHorizontalScrollIndicator?: boolean;
showsVerticalScrollIndicator?: boolean;
forceLightScrollIndicators?: boolean;
source: any;
userAgent?: string;
/**
Expand Down Expand Up @@ -293,9 +294,16 @@ export interface IOSWebViewProps extends WebViewSharedProps {
* @platform ios
*/
scrollEnabled?: boolean;
/**
* Boolean value that determines whether scrolling to the top is enabled
* when the user taps the status bar. The default value is `true`.
*
* @platform ios
*/
scrollsToTop?: boolean;
/**
* If the value of this property is true, the scroll view stops on multiples
* of the scroll views bounds when the user scrolls.
* of the scroll view's bounds when the user scrolls.
* The default value is false.
* @platform ios
*/
Expand Down Expand Up @@ -1023,6 +1031,12 @@ export interface WebViewSharedProps extends ViewProps {
* shown in the `WebView`. The default value is `true`.
*/
showsVerticalScrollIndicator?: boolean;
/**
* Boolean value that determines whether a light scrollbar is
* shown in the `WebView`. The default value is `false`.
* @platform ios
*/
forceLightScrollIndicators?: boolean;
/**
* Boolean that determines whether HTML5 audio and video requires the user
* to tap them before they start playing. The default value is `true`.
Expand Down
2 changes: 1 addition & 1 deletion lib/WebViewTypes.d.ts.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/RNCWebViewNativeComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export interface NativeProps extends ViewProps {
showsHorizontalScrollIndicator?: boolean;
showsVerticalScrollIndicator?: boolean;
forceLightScrollIndicators?: boolean;
scrollsToTop?: boolean;
newSource: Readonly<{
uri?: string
method?: string;
Expand Down
26 changes: 17 additions & 9 deletions src/WebViewTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export interface WebViewCustomMenuItems {
label: string;
}

export declare type SuppressMenuItem =
export declare type SuppressMenuItem =
| "cut"
| "copy"
| "paste"
Expand Down Expand Up @@ -377,10 +377,10 @@ export interface WindowsWebViewProps extends WebViewSharedProps {
useWebView2?: boolean;
/**
* Function that is invoked when the `WebView` should open a new window.
*
*
* This happens when the JS calls `window.open('http://someurl', '_blank')`
* or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
*
*
* Only works with `useWebView2` set to `true`.
*
* @platform windows
Expand All @@ -390,9 +390,9 @@ export interface WindowsWebViewProps extends WebViewSharedProps {
/**
* Function that is invoked when the `WebView` responds to a request to load a new resource.
* Works only on Windows.
*
*
* Only works with `useWebView2` set to `true`.
*
*
* @platform windows
*/
onSourceChanged?: (event: WebViewNavigationEvent) => void;
Expand Down Expand Up @@ -431,9 +431,17 @@ export interface IOSWebViewProps extends WebViewSharedProps {
*/
scrollEnabled?: boolean;

/**
* Boolean value that determines whether scrolling to the top is enabled
* when the user taps the status bar. The default value is `true`.
*
* @platform ios
*/
scrollsToTop?: boolean;

/**
* If the value of this property is true, the scroll view stops on multiples
* of the scroll views bounds when the user scrolls.
* of the scroll view's bounds when the user scrolls.
* The default value is false.
* @platform ios
*/
Expand Down Expand Up @@ -630,7 +638,7 @@ export interface IOSWebViewProps extends WebViewSharedProps {

/**
* Function that is invoked when the `WebView` should open a new window.
*
*
* This happens when the JS calls `window.open('http://someurl', '_blank')`
* or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
*
Expand Down Expand Up @@ -926,7 +934,7 @@ export interface AndroidWebViewProps extends WebViewSharedProps {

/**
* Function that is invoked when the `WebView` should open a new window.
*
*
* This happens when the JS calls `window.open('http://someurl', '_blank')`
* or when the user clicks on a `<a href="http://someurl" target="_blank">` link.
*
Expand Down Expand Up @@ -1316,7 +1324,7 @@ export interface WebViewSharedProps extends ViewProps {
* Inject a JavaScript object to be accessed as a JSON string via JavaScript in the WebView.
*/
injectedJavaScriptObject?: object;

/**
* Enables WebView remote debugging using Chrome (Android) or Safari (iOS).
*/
Expand Down
Loading