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
 
70
 
71
   webViewRef = React.createRef<NativeWebViewAndroid>();
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
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
82
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
74
 
83
 
75
   goForward = () => {
84
   goForward = () => {

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

74
 
74
 
75
   webViewRef = React.createRef<NativeWebViewIOS>();
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
   // eslint-disable-next-line react/sort-comp
86
   // eslint-disable-next-line react/sort-comp
78
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
87
   getCommands = () => UIManager.getViewManagerConfig('RNCWebView').Commands;
79
 
88
 

+ 18
- 3
src/WebViewTypes.ts View File

52
 // eslint-disable-next-line react/prefer-stateless-function
52
 // eslint-disable-next-line react/prefer-stateless-function
53
 declare class NativeWebViewIOSComponent extends Component<
53
 declare class NativeWebViewIOSComponent extends Component<
54
   IOSNativeWebViewProps
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
 declare const NativeWebViewIOSBase: Constructor<NativeMethodsMixin> &
63
 declare const NativeWebViewIOSBase: Constructor<NativeMethodsMixin> &
57
   typeof NativeWebViewIOSComponent;
64
   typeof NativeWebViewIOSComponent;
58
-export class NativeWebViewIOS extends NativeWebViewIOSBase {}
65
+export class NativeWebViewIOS extends NativeWebViewIOSBase {
66
+}
59
 
67
 
60
 // eslint-disable-next-line react/prefer-stateless-function
68
 // eslint-disable-next-line react/prefer-stateless-function
61
 declare class NativeWebViewMacOSComponent extends Component<
69
 declare class NativeWebViewMacOSComponent extends Component<
68
 // eslint-disable-next-line react/prefer-stateless-function
76
 // eslint-disable-next-line react/prefer-stateless-function
69
 declare class NativeWebViewAndroidComponent extends Component<
77
 declare class NativeWebViewAndroidComponent extends Component<
70
   AndroidNativeWebViewProps
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
 declare const NativeWebViewAndroidBase: Constructor<NativeMethodsMixin> &
87
 declare const NativeWebViewAndroidBase: Constructor<NativeMethodsMixin> &
73
   typeof NativeWebViewAndroidComponent;
88
   typeof NativeWebViewAndroidComponent;
74
 export class NativeWebViewAndroid extends NativeWebViewAndroidBase {}
89
 export class NativeWebViewAndroid extends NativeWebViewAndroidBase {}