Get the y scroll position in the detail view using window.pageYOffset instead of document.body.scrollTop. It appears the latter may be broken — at any rate, it just returns 0 on Catalina. (On Mojave, use the same method as before, so as not to risk a regression.)

This commit is contained in:
Brent Simmons 2019-10-18 17:37:56 -07:00
parent 56fab24cec
commit a11e900a93
1 changed files with 4 additions and 1 deletions

View File

@ -186,7 +186,10 @@ private extension DetailWebViewController {
}
func fetchScrollInfo(_ callback: @escaping (ScrollInfo?) -> Void) {
let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x"
var javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x"
if #available(macOS 10.15, *) {
javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
}
webView.evaluateJavaScript(javascriptString) { (info, error) in
guard let info = info as? [String: Any] else {