Don't scroll to bottom on load, since we scroll to focused when view

appears.

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 405edaa125
commit 457d6c6d95

@ -100,7 +100,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
let footerItems = [ let footerItems = [
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil), UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
deleteButton, deleteButton,
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target:nil, action:nil), UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
] ]
footerBar.setItems(footerItems, animated: false) footerBar.setItems(footerItems, animated: false)
@ -111,9 +111,6 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
self.footerBarBottomConstraint = footerBar.autoPinEdge(toSuperviewEdge: .bottom, withInset: -kFooterBarHeight) self.footerBarBottomConstraint = footerBar.autoPinEdge(toSuperviewEdge: .bottom, withInset: -kFooterBarHeight)
updateSelectButton() updateSelectButton()
self.view.layoutIfNeeded()
scrollToBottom(animated: false)
} }
private func indexPath(galleryItem: MediaGalleryItem) -> IndexPath? { private func indexPath(galleryItem: MediaGalleryItem) -> IndexPath? {
@ -140,7 +137,9 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
} }
Logger.debug("\(logTag) scrolling to focused item at indexPath: \(indexPath)") Logger.debug("\(logTag) scrolling to focused item at indexPath: \(indexPath)")
self.view.layoutIfNeeded()
self.collectionView?.scrollToItem(at: indexPath, at: .centeredVertically, animated: false) self.collectionView?.scrollToItem(at: indexPath, at: .centeredVertically, animated: false)
self.autoLoadMoreIfNecessary()
} }
// MARK: UICollectionViewDelegate // MARK: UICollectionViewDelegate
@ -714,20 +713,6 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
} }
} }
} }
// MARK: Util
private func scrollToBottom(animated isAnimated: Bool) {
guard let collectionView = self.collectionView else {
owsFail("\(self.logTag) in \(#function) collectionView was unexpectedly nil")
return
}
let yOffset: CGFloat = collectionView.contentSize.height - collectionView.bounds.size.height + collectionView.contentInset.bottom
let offset: CGPoint = CGPoint(x: 0, y: yOffset)
collectionView.setContentOffset(offset, animated: isAnimated)
}
} }
// MARK: - Private Helper Classes // MARK: - Private Helper Classes
@ -735,7 +720,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa
// Accomodates remaining scrolled to the same "apparent" position when new content is insterted // Accomodates remaining scrolled to the same "apparent" position when new content is insterted
// into the top of a collectionView. There are multiple ways to solve this problem, but this // into the top of a collectionView. There are multiple ways to solve this problem, but this
// is the only one which avoided a perceptible flicker. // is the only one which avoided a perceptible flicker.
fileprivate class MediaTileViewLayout: UICollectionViewFlowLayout { private class MediaTileViewLayout: UICollectionViewFlowLayout {
fileprivate var isInsertingCellsToTop: Bool = false fileprivate var isInsertingCellsToTop: Bool = false
fileprivate var contentSizeBeforeInsertingToTop: CGSize? fileprivate var contentSizeBeforeInsertingToTop: CGSize?
@ -756,7 +741,7 @@ fileprivate class MediaTileViewLayout: UICollectionViewFlowLayout {
} }
} }
fileprivate class MediaGallerySectionHeader: UICollectionReusableView { private class MediaGallerySectionHeader: UICollectionReusableView {
static let reuseIdentifier = "MediaGallerySectionHeader" static let reuseIdentifier = "MediaGallerySectionHeader"
@ -818,7 +803,7 @@ fileprivate class MediaGallerySectionHeader: UICollectionReusableView {
} }
} }
fileprivate class MediaGalleryStaticHeader: UICollectionViewCell { private class MediaGalleryStaticHeader: UICollectionViewCell {
static let reuseIdentifier = "MediaGalleryStaticHeader" static let reuseIdentifier = "MediaGalleryStaticHeader"
@ -848,7 +833,7 @@ fileprivate class MediaGalleryStaticHeader: UICollectionViewCell {
} }
} }
fileprivate class MediaGalleryCell: UICollectionViewCell { private class MediaGalleryCell: UICollectionViewCell {
static let reuseIdentifier = "MediaGalleryCell" static let reuseIdentifier = "MediaGalleryCell"

Loading…
Cancel
Save