Don't reset the windowScrollY position on every page render and don't set it if JavaScript returns it corrupted. Issue #1883

This commit is contained in:
Maurice Parker 2020-03-11 19:45:45 -05:00
parent 27b1443def
commit 22b9e7b54b
1 changed files with 6 additions and 4 deletions

View File

@ -375,8 +375,12 @@ extension WebViewController: UIScrollViewDelegate {
}
@objc func scrollPositionDidChange() {
webView?.evaluateJavaScript("window.scrollY") { (scrollY, _) in
self.windowScrollY = scrollY as? Int ?? 0
webView?.evaluateJavaScript("window.scrollY") { (scrollY, error) in
guard error == nil else { return }
let javascriptScrollY = scrollY as? Int ?? 0
// I don't know why this value gets returned sometimes, but it is in error
guard javascriptScrollY != 33554432 else { return }
self.windowScrollY = javascriptScrollY
}
}
@ -498,8 +502,6 @@ private extension WebViewController {
render = "render(\(json), \(windowScrollY));"
}
windowScrollY = 0
webView.evaluateJavaScript(render)
}