This commit is contained in:
Suresh, Kamlesh 2020-08-25 19:34:25 -04:00
parent f3c3ba9799
commit dce1c5cdf2

View File

@ -129,7 +129,6 @@ extension WebView : WKUIDelegate {
return
}
/*
//TODO: Check and remove the comment
was using "document.readyState" to check the state,
while evaluateJavaScript "document.readyState",only works when webview contains userscrpt.otherwise, it would return WKErrorDomain Code=4 "A JavaScript exception occurred".
so webView.isLoading to check load finished state
@ -140,17 +139,16 @@ extension WebView : WKUIDelegate {
return
}
MVMCoreDispatchUtility.performBlock(onMainThread: { [weak self] in
let scrollHeight = webView.scrollView.contentSize.height
guard let self = self else {
return
}
if let height = result as? CGFloat {
self.webViewHeight?.constant = height
} else {
//if failed to get height from javascript, using scrollview.contensize's height
self.webViewHeight?.constant = scrollHeight
}
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
if let height = result as? CGFloat {
self.webViewHeight?.constant = height
} else {
//if failed to get height from javascript, using scrollview.contensize's height
self.webViewHeight?.constant = webView.scrollView.contentSize.height
}
self.delegateObject?.moleculeDelegate?.moleculeLayoutUpdated(self)
})
})
}