parent
1ce48bc77e
commit
984ecc8879
|
@ -283,11 +283,21 @@ class BrowserWebViewController: UIViewController {
|
||||||
let y = result * scrollView.zoomScale - scrollView.safeAreaInsets.top
|
let y = result * scrollView.zoomScale - scrollView.safeAreaInsets.top
|
||||||
let maxY = scrollView.contentSize.height - scrollView.bounds.height + scrollView.safeAreaInsets.bottom
|
let maxY = scrollView.contentSize.height - scrollView.bounds.height + scrollView.safeAreaInsets.bottom
|
||||||
let finalOffsetY = min(y, maxY)
|
let finalOffsetY = min(y, maxY)
|
||||||
self.webView.scrollView.setContentOffset(CGPoint(x: 0, y: finalOffsetY), animated: true)
|
UIView.animate(withDuration: 0.25, delay: 0, options: []) {
|
||||||
|
self.webView.scrollView.setContentOffset(CGPoint(x: 0, y: finalOffsetY), animated: false)
|
||||||
|
} completion: { _ in
|
||||||
|
// calling focus() causes VoiceOver to move to that element
|
||||||
|
self.webView.evaluateJavaScript("document.getElementById('l\(index)').focus();")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
webView.evaluateJavaScript("document.getElementById('l\(index)').scrollIntoView();")
|
webView.evaluateJavaScript("""
|
||||||
|
const el = document.getElementById('l\(index)');
|
||||||
|
el.scrollIntoView();
|
||||||
|
el.focus();
|
||||||
|
""")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static let preamble = """
|
private static let preamble = """
|
||||||
|
|
Loading…
Reference in New Issue