From a11e900a93800afd26cba52e2ab76018358c9314 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 18 Oct 2019 17:37:56 -0700 Subject: [PATCH] =?UTF-8?q?Get=20the=20y=20scroll=20position=20in=20the=20?= =?UTF-8?q?detail=20view=20using=20window.pageYOffset=20instead=20of=20doc?= =?UTF-8?q?ument.body.scrollTop.=20It=20appears=20the=20latter=20may=20be?= =?UTF-8?q?=20broken=20=E2=80=94=C2=A0at=20any=20rate,=20it=20just=20retur?= =?UTF-8?q?ns=200=20on=20Catalina.=20(On=20Mojave,=20use=20the=20same=20me?= =?UTF-8?q?thod=20as=20before,=20so=20as=20not=20to=20risk=20a=20regressio?= =?UTF-8?q?n.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mac/MainWindow/Detail/DetailWebViewController.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 4320bfa99..bd913e5cc 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -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 {