Nizomiddin Toshpulatov 4 years ago
parent
commit
8cc3a124eb
No account linked to committer's email address
2 changed files with 38 additions and 2 deletions
  1. 34
    0
      docs/Reference.md
  2. 4
    2
      src/WebViewTypes.ts

+ 34
- 0
docs/Reference.md View File

22
 - [`onMessage`](Reference.md#onmessage)
22
 - [`onMessage`](Reference.md#onmessage)
23
 - [`onNavigationStateChange`](Reference.md#onnavigationstatechange)
23
 - [`onNavigationStateChange`](Reference.md#onnavigationstatechange)
24
 - [`onContentProcessDidTerminate`](Reference.md#oncontentprocessdidterminate)
24
 - [`onContentProcessDidTerminate`](Reference.md#oncontentprocessdidterminate)
25
+- [`onScroll`](Reference.md#onscroll)
25
 - [`originWhitelist`](Reference.md#originwhitelist)
26
 - [`originWhitelist`](Reference.md#originwhitelist)
26
 - [`renderError`](Reference.md#rendererror)
27
 - [`renderError`](Reference.md#rendererror)
27
 - [`renderLoading`](Reference.md#renderloading)
28
 - [`renderLoading`](Reference.md#renderloading)
578
 
579
 
579
 ---
580
 ---
580
 
581
 
582
+### `onScroll`[⬆](#props-index)<!-- Link generated with jump2header -->
583
+
584
+Function that is invoked when the scroll event is fired in the `WebView`.
585
+
586
+| Type     | Required | Platform                |
587
+| -------- | -------- | ----------------------- |
588
+| function | No       | iOS, macOS, Android, Windows |
589
+
590
+Example:
591
+
592
+```jsx
593
+<Webview
594
+  source={{ uri: 'https://reactnative.dev' }}
595
+  onScroll={syntheticEvent => {
596
+    const { contentOffset } = syntheticEvent.nativeEvent
597
+    console.table(contentOffset)
598
+  }}
599
+/>
600
+```
601
+
602
+Function passed to `onScroll` is called with a SyntheticEvent wrapping a nativeEvent with these properties:
603
+
604
+```
605
+contentInset
606
+contentOffset
607
+contentSize
608
+layoutMeasurement
609
+velocity
610
+zoomScale
611
+```
612
+
613
+---
614
+
581
 ### `originWhitelist`[⬆](#props-index)<!-- Link generated with jump2header -->
615
 ### `originWhitelist`[⬆](#props-index)<!-- Link generated with jump2header -->
582
 
616
 
583
 List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _just_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://*" and "https://*".
617
 List of origin strings to allow being navigated to. The strings allow wildcards and get matched against _just_ the origin (not the full URL). If the user taps to navigate to a new page but the new page is not in this whitelist, the URL will be handled by the OS. The default whitelisted origins are "http://*" and "https://*".

+ 4
- 2
src/WebViewTypes.ts View File

167
 
167
 
168
 export type WebViewRenderProcessGoneEvent = NativeSyntheticEvent<WebViewRenderProcessGoneDetail>;
168
 export type WebViewRenderProcessGoneEvent = NativeSyntheticEvent<WebViewRenderProcessGoneDetail>;
169
 
169
 
170
+export type WebViewScrollEvent = NativeSyntheticEvent<NativeScrollEvent>;
171
+
170
 export type DataDetectorTypes =
172
 export type DataDetectorTypes =
171
   | 'phoneNumber'
173
   | 'phoneNumber'
172
   | 'link'
174
   | 'link'
259
   javaScriptCanOpenWindowsAutomatically?: boolean;
261
   javaScriptCanOpenWindowsAutomatically?: boolean;
260
   mediaPlaybackRequiresUserAction?: boolean;
262
   mediaPlaybackRequiresUserAction?: boolean;
261
   messagingEnabled: boolean;
263
   messagingEnabled: boolean;
262
-  onScroll?: (event: NativeScrollEvent) => void;
264
+  onScroll?: (event: WebViewScrollEvent) => void;
263
   onLoadingError: (event: WebViewErrorEvent) => void;
265
   onLoadingError: (event: WebViewErrorEvent) => void;
264
   onLoadingFinish: (event: WebViewNavigationEvent) => void;
266
   onLoadingFinish: (event: WebViewNavigationEvent) => void;
265
   onLoadingProgress: (event: WebViewProgressEvent) => void;
267
   onLoadingProgress: (event: WebViewProgressEvent) => void;
913
   /**
915
   /**
914
    * Function that is invoked when the `WebView` scrolls.
916
    * Function that is invoked when the `WebView` scrolls.
915
    */
917
    */
916
-  onScroll?: (event: NativeScrollEvent) => void;
918
+  onScroll?: (event: WebViewScrollEvent) => void;
917
 
919
 
918
   /**
920
   /**
919
    * Function that is invoked when the `WebView` has finished loading.
921
    * Function that is invoked when the `WebView` has finished loading.