Skip to content
This repository was archived by the owner on Sep 25, 2021. It is now read-only.

Commit d6a54a3

Browse files
authored
Merge pull request #116 from turbolinks/fix-scrolling
Fix scroll position being incorrect
2 parents cab8da6 + ad87805 commit d6a54a3

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Turbolinks/VisitableView.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ open class VisitableView: UIView {
3232
self.visitable = visitable
3333
addSubview(webView)
3434
addFillConstraints(forView: webView)
35-
updateContentInsets()
3635
installRefreshControl()
3736
showOrHideWebView()
3837
}
@@ -199,7 +198,11 @@ open class VisitableView: UIView {
199198
}
200199

201200
private func updateContentInsets() {
202-
updateWebViewScrollViewInsets(contentInset ?? hiddenScrollView.contentInset)
201+
if #available(iOS 11, *) {
202+
updateWebViewScrollViewInsets(contentInset ?? hiddenScrollView.adjustedContentInset)
203+
} else {
204+
updateWebViewScrollViewInsets(contentInset ?? hiddenScrollView.contentInset)
205+
}
203206
}
204207

205208
private func addFillConstraints(forView view: UIView) {

Turbolinks/WebView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class WebView: WKWebView {
3636

3737
translatesAutoresizingMaskIntoConstraints = false
3838
scrollView.decelerationRate = UIScrollViewDecelerationRateNormal
39+
40+
if #available(iOS 11, *) {
41+
scrollView.contentInsetAdjustmentBehavior = .never
42+
}
3943
}
4044

4145
required init?(coder: NSCoder) {

TurbolinksDemo/ApplicationController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class ApplicationController: UINavigationController {
2626

2727
override func viewDidLoad() {
2828
super.viewDidLoad()
29+
30+
// Switching this to false will prevent content from sitting beneath scrollbar
31+
navigationBar.isTranslucent = true
32+
2933
presentVisitableForSession(session, url: url)
3034
}
3135

0 commit comments

Comments
 (0)