From 88f565e03f54b3acc08fd3c230cdca6938497fc8 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sun, 19 Jan 2020 11:48:26 -0700 Subject: [PATCH] Use the DOM Y position to restore the scroll offset. This mostly fixes Issue #1494. --- iOS/Article/WebViewController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index eee317fa2..16415a8dc 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -180,9 +180,9 @@ class WebViewController: UIViewController { } func fullReload() { - if let offset = webView?.scrollView.contentOffset.y { - restoreOffset = Int(offset) - webView?.reload() + webView?.evaluateJavaScript("window.scrollY") { (scrollY, _) in + self.restoreOffset = scrollY as! Int + self.reloadHTML() } } @@ -436,7 +436,9 @@ private extension WebViewController { // play on the iPad where we aren't constantly pushing and popping this controller. if (renderingTracker > 10) { reloadHTML() + return } + renderingTracker += 1 let style = ArticleStylesManager.shared.currentStyle