Skip to content

Commit

Permalink
Merge pull request #2229 from minvws/bugfix/disable-horizontal-scrolling
Browse files Browse the repository at this point in the history
Disable horizontal scrolling on iPad
  • Loading branch information
iandundas authored Jan 12, 2023
2 parents dacc4d7 + cff4945 commit c30334f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Sources/CTR/Interface/Common/ScrolledStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ScrolledStackView: BaseView {
}()

/// Content view to get proper size in scroll view
let contentScrollView: UIView = {
let scrollViewContent: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
Expand All @@ -60,8 +60,8 @@ class ScrolledStackView: BaseView {
override func setupViewHierarchy() {

super.setupViewHierarchy()
stackView.embed(in: contentScrollView)
scrollView.addSubview(contentScrollView)
stackView.embed(in: scrollViewContent)
scrollView.addSubview(scrollViewContent)
addSubview(scrollView)
}

Expand All @@ -85,15 +85,14 @@ class ScrolledStackView: BaseView {
}(),

// Content view
contentScrollView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: stackViewInset.left),
contentScrollView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor, constant: -stackViewInset.right),
contentScrollView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: stackViewInset.top),
contentScrollView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: -stackViewInset.bottom),
contentScrollView.widthAnchor.constraint(equalTo: scrollView.widthAnchor, constant: -stackViewInset.left - stackViewInset.right),
scrollViewContent.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor, constant: stackViewInset.left),
scrollViewContent.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: stackViewInset.top),
scrollViewContent.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: -stackViewInset.bottom),
scrollViewContent.widthAnchor.constraint(equalTo: scrollView.widthAnchor, constant: -stackViewInset.left - stackViewInset.right),

// StackView
stackView.widthAnchor.constraint(equalTo: contentScrollView.widthAnchor),
stackView.centerXAnchor.constraint(equalTo: contentScrollView.centerXAnchor)
stackView.widthAnchor.constraint(equalTo: scrollViewContent.widthAnchor),
stackView.centerXAnchor.constraint(equalTo: scrollViewContent.centerXAnchor)
])
}
}

0 comments on commit c30334f

Please sign in to comment.