From 6aa7b009f8f776d26adcc83fdfe2b4429a160751 Mon Sep 17 00:00:00 2001 From: Brian Sanders Date: Sun, 7 Jun 2020 20:05:56 -0400 Subject: [PATCH] Tweaks the scroll behavior when space bar is pressed The overlap is 2 lines of text at the standard system font size. --- iOS/Article/WebViewController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index 83dba122d..5598abfec 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -128,8 +128,9 @@ class WebViewController: UIViewController { func scrollPageDown() { guard let webView = webView else { return } + let overlap = 2 * UIFont.systemFont(ofSize: UIFont.systemFontSize).lineHeight * UIScreen.main.scale let scrollToY: CGFloat = { - let fullScroll = webView.scrollView.contentOffset.y + webView.scrollView.layoutMarginsGuide.layoutFrame.height + let fullScroll = webView.scrollView.contentOffset.y + webView.scrollView.layoutMarginsGuide.layoutFrame.height - overlap let final = finalScrollPosition() return fullScroll < final ? fullScroll : final }()