Jamie Birch 4 years ago
parent
commit
bd73f6632b
No account linked to committer's email address
3 changed files with 36 additions and 3 deletions
  1. 9
    0
      src/WebView.android.tsx
  2. 9
    0
      src/WebView.ios.tsx
  3. 18
    3
      src/WebViewTypes.ts

+ 9
- 0
src/WebView.android.tsx View File

@@ -70,6 +70,15 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
70 70
 
71 71
   webViewRef = React.createRef<NativeWebViewAndroid>();
72 72
 
73
+  /** 
74
+   * Required to allow createAnimatedComponent() to hook up to the underlying NativeWebView rather than its wrapping View.
75
+   * @see: Discussion: https://twitter.com/LinguaBrowse/status/1211375582073761799?s=20
76
+   * @see: Implementation: https://github.com/facebook/react-native/blob/8ddf231306e3bd85be718940d04f11d23b570a62/Libraries/Lists/VirtualizedList.js#L515-L521
77
+   */
78
+  getScrollableNode = () => {
79
+    return this.webViewRef.current;
80
+  };
81
+
73 82
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
74 83
 
75 84
   goForward = () => {

+ 9
- 0
src/WebView.ios.tsx View File

@@ -74,6 +74,15 @@ class WebView extends React.Component<IOSWebViewProps, State> {
74 74
 
75 75
   webViewRef = React.createRef<NativeWebViewIOS>();
76 76
 
77
+  /** 
78
+   * Required to allow createAnimatedComponent() to hook up to the underlying NativeWebView rather than its wrapping View.
79
+   * @see: Discussion: https://twitter.com/LinguaBrowse/status/1211375582073761799?s=20
80
+   * @see: Implementation: https://github.com/facebook/react-native/blob/8ddf231306e3bd85be718940d04f11d23b570a62/Libraries/Lists/VirtualizedList.js#L515-L521
81
+   */
82
+  getScrollableNode = () => {
83
+    return this.webViewRef.current;
84
+  };
85
+
77 86
   // eslint-disable-next-line react/sort-comp
78 87
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
79 88
 

+ 18
- 3
src/WebViewTypes.ts View File

@@ -52,10 +52,18 @@ export type State = NormalState | ErrorState;
52 52
 // eslint-disable-next-line react/prefer-stateless-function
53 53
 declare class NativeWebViewIOSComponent extends Component<
54 54
   IOSNativeWebViewProps
55
-> {}
55
+> {
56
+  /** 
57
+   * Required to allow createAnimatedComponent() to hook up to the underlying NativeWebView rather than its wrapping View.
58
+   * @see: Discussion: https://twitter.com/LinguaBrowse/status/1211375582073761799?s=20
59
+   * @see: Implementation: https://github.com/facebook/react-native/blob/8ddf231306e3bd85be718940d04f11d23b570a62/Libraries/Lists/VirtualizedList.js#L515-L521
60
+   */
61
+  getScrollableNode(): number | null;
62
+}
56 63
 declare const NativeWebViewIOSBase: Constructor<NativeMethodsMixin> &
57 64
   typeof NativeWebViewIOSComponent;
58
-export class NativeWebViewIOS extends NativeWebViewIOSBase {}
65
+export class NativeWebViewIOS extends NativeWebViewIOSBase {
66
+}
59 67
 
60 68
 // eslint-disable-next-line react/prefer-stateless-function
61 69
 declare class NativeWebViewMacOSComponent extends Component<
@@ -68,7 +76,14 @@ export class NativeWebViewMacOS extends NativeWebViewMacOSBase {}
68 76
 // eslint-disable-next-line react/prefer-stateless-function
69 77
 declare class NativeWebViewAndroidComponent extends Component<
70 78
   AndroidNativeWebViewProps
71
-> {}
79
+> {
80
+  /** 
81
+   * Required to allow createAnimatedComponent() to hook up to the underlying NativeWebView rather than its wrapping View.
82
+   * @see: Discussion: https://twitter.com/LinguaBrowse/status/1211375582073761799?s=20
83
+   * @see: Implementation: https://github.com/facebook/react-native/blob/8ddf231306e3bd85be718940d04f11d23b570a62/Libraries/Lists/VirtualizedList.js#L515-L521
84
+   */
85
+  getScrollableNode(): number | null;
86
+}
72 87
 declare const NativeWebViewAndroidBase: Constructor<NativeMethodsMixin> &
73 88
   typeof NativeWebViewAndroidComponent;
74 89
 export class NativeWebViewAndroid extends NativeWebViewAndroidBase {}