diff --git a/harmony/rn_webview/src/main/ets/RNCWebView.ets b/harmony/rn_webview/src/main/ets/RNCWebView.ets index e54b9e199..1c03a6dc6 100644 --- a/harmony/rn_webview/src/main/ets/RNCWebView.ets +++ b/harmony/rn_webview/src/main/ets/RNCWebView.ets @@ -59,6 +59,7 @@ export interface WebViewProps extends ViewBaseProps { shouldStartLoadWithRequestEnabled: boolean webviewDebuggingEnabled: boolean // nestedScrollEnabled: boolean + scrollEnabled: boolean } export class RNCWebViewBridge { @@ -111,6 +112,7 @@ export struct RNCWebView { controllerAttached: boolean = false; // nestedScrollFlag: boolean = false; renderMode: RenderMode = RenderMode.SYNC_RENDER; + scrollEnabled = true; aboutToAppear() { this.descriptor = this.ctx.descriptorRegistry.getDescriptor(this.tag) @@ -148,6 +150,7 @@ export struct RNCWebView { } ) webview.WebviewController.setWebDebuggingAccess(this.descriptor.props.webviewDebuggingEnabled) + this.scrollEnabled = this.descriptor.props.scrollEnabled; this.javaScriptEnable = this.descriptor.props.javaScriptEnabled; this.cacheMode = this.descriptor.props.cacheEnabled ? this.transCacheMode(this.descriptor.props.cacheMode) : CacheMode.Online; @@ -288,6 +291,20 @@ export struct RNCWebView { }); } + onLoadingStart() { + this.ctx.rnInstance.emitComponentEvent(this.descriptor.tag, WEB_VIEW, { + type: "onLoadingStart", + url: this.controller.getUrl(), + loading: this.progress != 100, + title: this.controller.getTitle(), + canGoBack: this.controller.accessBackward(), + canGoForward: this.controller.accessForward(), + lockIdentifier: 0, + navigationType: "other", + mainDocumentURL: "" + }) + } + onLoadingFinish() { this.ctx.rnInstance.emitComponentEvent(this.descriptor.tag, WEB_VIEW, { type: "onLoadingFinish", @@ -396,6 +413,10 @@ export struct RNCWebView { Logger.debug(TAG, "[RNOH] event progress: " + event.newProgress) } }) + .onPageBegin(() => { + this.onLoadingStart() + this.controller.setScrollable(this.scrollEnabled) + }) .onPageEnd(() => { Logger.debug(TAG, "[RNOH] onPageEnd") this.runInjectedJavaScript() @@ -405,11 +426,6 @@ export struct RNCWebView { if (event) { let errorInfo: string = event.error.getErrorInfo(); let errorCode: number = event.error.getErrorCode(); - if (errorInfo == "ERR_INTERNET_DISCONNECTED" || errorInfo == "ERR_CACHE_MISS" || - !event.request.isMainFrame()) { - Logger.debug(TAG, "[RNOH] ERR_INTERNET_DISCONNECTED:OR ERR_CACHE_MISS") - return - } Logger.debug(TAG, "[RNOH] errorInfo:" + errorInfo) Logger.debug(TAG, "[RNOH] errorCode:" + errorCode) this.onLoadingError(errorCode, errorInfo)