Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue that the article webView don’t show up on launch until it finishes loading all the page resources. #4032

Open
wants to merge 1 commit into
base: detour2023
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Mac/MainWindow/Detail/DetailWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ extension DetailWebViewController: WKNavigationDelegate, WKUIDelegate {
decisionHandler(.allow)
}

public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
public func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
// See note in viewDidLoad()
if waitingForFirstReload {
assert(webView.isHidden)
Expand All @@ -252,11 +252,14 @@ extension DetailWebViewController: WKNavigationDelegate, WKUIDelegate {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
webView.isHidden = false
}
} else {
if let windowScrollY = windowScrollY {
webView.evaluateJavaScript("window.scrollTo(0, \(windowScrollY));")
self.windowScrollY = nil
}
}
}

public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
assert(!waitingForFirstReload)
if let windowScrollY = windowScrollY {
webView.evaluateJavaScript("window.scrollTo(0, \(windowScrollY));")
self.windowScrollY = nil
}
}

Expand Down