Fix stretchy menu interaction not working on iPad

This commit is contained in:
Shadowfacts 2022-06-20 11:26:05 -04:00
parent 1e7e8b7f85
commit 8db60a313e
2 changed files with 6 additions and 2 deletions

View File

@ -61,7 +61,8 @@ class ReadViewController: UIViewController {
navigationItem.largeTitleDisplayMode = .never navigationItem.largeTitleDisplayMode = .never
view.backgroundColor = .appBackground view.backgroundColor = .appBackground
view.addInteraction(StretchyMenuInteraction(delegate: self)) let menuInteraction = StretchyMenuInteraction(delegate: self)
view.addInteraction(menuInteraction)
webView = WKWebView() webView = WKWebView()
webView.translatesAutoresizingMaskIntoConstraints = false webView.translatesAutoresizingMaskIntoConstraints = false
@ -77,6 +78,8 @@ class ReadViewController: UIViewController {
if let content = itemContentHTML() { if let content = itemContentHTML() {
webView.loadHTMLString(content, baseURL: item.url) webView.loadHTMLString(content, baseURL: item.url)
} }
webView.scrollView.alwaysBounceHorizontal = false
webView.scrollView.panGestureRecognizer.require(toFail: menuInteraction.panRecognizer!)
view.addSubview(webView) view.addSubview(webView)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([

View File

@ -23,6 +23,7 @@ class StretchyMenuInteraction: NSObject, UIInteraction {
weak var delegate: StretchyMenuInteractionDelegate? weak var delegate: StretchyMenuInteractionDelegate?
private(set) weak var view: UIView? = nil private(set) weak var view: UIView? = nil
private(set) var panRecognizer: UIPanGestureRecognizer?
private let menuHintView = MenuHintView() private let menuHintView = MenuHintView()
fileprivate let feedbackGenerator = UIImpactFeedbackGenerator(style: .medium) fileprivate let feedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
@ -56,7 +57,7 @@ class StretchyMenuInteraction: NSObject, UIInteraction {
panRecognizer.delegate = self panRecognizer.delegate = self
panRecognizer.allowedScrollTypesMask = [.continuous] panRecognizer.allowedScrollTypesMask = [.continuous]
view.addGestureRecognizer(panRecognizer) view.addGestureRecognizer(panRecognizer)
self.panRecognizer = panRecognizer
} }
private var prevTranslation: CGFloat = 0 private var prevTranslation: CGFloat = 0