fiix
This commit is contained in:
parent
61c3231965
commit
db851b00a9
@ -128,23 +128,31 @@ extension WebView : WKUIDelegate {
|
||||
if !dynamicHeight {
|
||||
return
|
||||
}
|
||||
/* 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".
|
||||
/*
|
||||
//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
|
||||
*/
|
||||
if !webView.isLoading {
|
||||
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
|
||||
guard let self = self else {
|
||||
webView.evaluateJavaScript("document.readyState", completionHandler: { (complete, error) in
|
||||
if complete == nil {
|
||||
return
|
||||
}
|
||||
let scrollHeight = self.webView?.scrollView.contentSize.height ?? 44.0
|
||||
if let height = result as? CGFloat,
|
||||
height < scrollHeight {
|
||||
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)
|
||||
webView.evaluateJavaScript("document.body.scrollHeight", completionHandler: { [weak self] (result, error) in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
let scrollHeight = self.webView?.scrollView.contentSize.height ?? 44.0
|
||||
if let height = result as? CGFloat,
|
||||
height < scrollHeight {
|
||||
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)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user