Преглед изворни кода

Merge pull request #37 from Barylskyigb/patch-1

Make it possible to use stopLoading function of react-native's WebView
iou90 пре 6 година
родитељ
комит
d0f7f26840
No account linked to committer's email address
2 измењених фајлова са 13 додато и 0 уклоњено
  1. 8
    0
      autoHeightWebView/index.android.js
  2. 5
    0
      autoHeightWebView/index.ios.js

+ 8
- 0
autoHeightWebView/index.android.js Прегледај датотеку

273
     onLoadEnd && onLoadEnd(event);
273
     onLoadEnd && onLoadEnd(event);
274
   };
274
   };
275
 
275
 
276
+  stopLoading() {
277
+    UIManager.dispatchViewManagerCommand(
278
+      findNodeHandle(this.webview),
279
+      UIManager.RCTAutoHeightWebView.Commands.stopLoading,
280
+      null
281
+    );
282
+  }
283
+
276
   render() {
284
   render() {
277
     const { height, script, isChangingSource, heightOffset } = this.state;
285
     const { height, script, isChangingSource, heightOffset } = this.state;
278
     const {
286
     const {

+ 5
- 0
autoHeightWebView/index.ios.js Прегледај датотеку

134
         }
134
         }
135
     }
135
     }
136
 
136
 
137
+    stopLoading() {
138
+        this.webview.stopLoading();   
139
+    }
140
+
137
     render() {
141
     render() {
138
         const { height, script } = this.state;
142
         const { height, script } = this.state;
139
         const { onError, onLoad, onLoadStart, onLoadEnd, onShouldStartLoadWithRequest, scalesPageToFit, enableAnimation, source, heightOffset, customScript, style } = this.props;
143
         const { onError, onLoad, onLoadStart, onLoadEnd, onShouldStartLoadWithRequest, scalesPageToFit, enableAnimation, source, heightOffset, customScript, style } = this.props;
144
                 height: height + heightOffset,
148
                 height: height + heightOffset,
145
             }, style]}>
149
             }, style]}>
146
                 <WebView
150
                 <WebView
151
+                    ref={webview => this.webview = webview}
147
                     onError={onError}
152
                     onError={onError}
148
                     onLoad={onLoad}
153
                     onLoad={onLoad}
149
                     onLoadStart={onLoadStart}
154
                     onLoadStart={onLoadStart}