forked from shadowfacts/Tusker
Fix multi column navigation not animating when scrolling back while replacing multiple columns
This commit is contained in:
parent
dcc5f7f716
commit
412c5ee91d
|
@ -17,7 +17,6 @@ protocol MultiColumnNavigationCustomTargetProviding {
|
|||
|
||||
class MultiColumnNavigationController: UIViewController {
|
||||
|
||||
private var isManuallyUpdating = false
|
||||
private var _viewControllers: [UIViewController] = []
|
||||
var viewControllers: [UIViewController] {
|
||||
get {
|
||||
|
@ -25,8 +24,7 @@ class MultiColumnNavigationController: UIViewController {
|
|||
}
|
||||
set {
|
||||
_viewControllers = newValue
|
||||
if isViewLoaded,
|
||||
!isManuallyUpdating {
|
||||
if isViewLoaded {
|
||||
updateViews()
|
||||
scrollToEnd(animated: false)
|
||||
}
|
||||
|
@ -143,7 +141,14 @@ class MultiColumnNavigationController: UIViewController {
|
|||
}
|
||||
|
||||
private func scrollColumnToEnd(columnIndex: Int, animated: Bool) {
|
||||
// Laying out may change the content offset if we have fewer columns than before,
|
||||
// but we want to keep the original offset so that we can animate smoothly to the final one.
|
||||
let origContentOffset = scrollView.contentOffset
|
||||
scrollView.layoutIfNeeded()
|
||||
if animated {
|
||||
scrollView.contentOffset = origContentOffset
|
||||
}
|
||||
|
||||
let column = stackView.arrangedSubviews[columnIndex]
|
||||
let columnFrame = column.convert(column.bounds, to: scrollView)
|
||||
let offset: CGFloat
|
||||
|
|
Loading…
Reference in New Issue