v2.2.1
✨ Improvements
Safely handle nil value in dynamic height update for WKWebView
- Updated webView(_:didFinish:navigation:) method to use optional binding for safely extracting height value.
- Set dynamicHeight to 0 if height is nil.
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("document.getElementById(\"NuPlay_RichText\").offsetHeight", completionHandler: { (height, _) in
DispatchQueue.main.async {
if let height = height as? CGFloat {
withAnimation(self.parent.conf.transition) {
self.parent.dynamicHeight = height
}
} else {
self.parent.dynamicHeight = 0
}
}
})
}
This update resolves the issue mentioned in #32 and has been implemented through PR #33.