Skip to content

v2.2.1

Compare
Choose a tag to compare
@NuPlay NuPlay released this 02 May 16:39
· 39 commits to main since this release
6e14ec7

✨ 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.