mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Stop album view jumping occasionally
This commit is contained in:
parent
0fb1831ffd
commit
fc99c59d53
@ -46,6 +46,10 @@ class AlbumViewController: NSViewController,
|
|||||||
override func viewWillLayout() {
|
override func viewWillLayout() {
|
||||||
super.viewWillLayout()
|
super.viewWillLayout()
|
||||||
|
|
||||||
|
if let layout = albumCollectionView.collectionViewLayout as? AlbumViewLayout {
|
||||||
|
layout.saveScrollPosition()
|
||||||
|
}
|
||||||
|
|
||||||
albumCollectionView.collectionViewLayout?.invalidateLayout()
|
albumCollectionView.collectionViewLayout?.invalidateLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,10 +36,6 @@ class AlbumViewLayout: NSCollectionViewFlowLayout {
|
|||||||
var divider: CGFloat = 1
|
var divider: CGFloat = 1
|
||||||
var itemWidth: CGFloat = 0
|
var itemWidth: CGFloat = 0
|
||||||
|
|
||||||
if let scrollView = collectionView.enclosingScrollView {
|
|
||||||
scrollPosition = scrollView.documentVisibleRect.minY / collectionView.bounds.height
|
|
||||||
}
|
|
||||||
|
|
||||||
repeat {
|
repeat {
|
||||||
let totalPaddingWidth = sectionInset.left + sectionInset.right
|
let totalPaddingWidth = sectionInset.left + sectionInset.right
|
||||||
let totalGutterWidth = (divider - 1) * (minimumInteritemSpacing)
|
let totalGutterWidth = (divider - 1) * (minimumInteritemSpacing)
|
||||||
@ -52,6 +48,15 @@ class AlbumViewLayout: NSCollectionViewFlowLayout {
|
|||||||
itemSize = NSSize(width: itemWidth, height: itemHeight)
|
itemSize = NSSize(width: itemWidth, height: itemHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func saveScrollPosition() {
|
||||||
|
guard let collectionView = collectionView
|
||||||
|
else { return }
|
||||||
|
|
||||||
|
if let scrollView = collectionView.enclosingScrollView {
|
||||||
|
scrollPosition = scrollView.documentVisibleRect.minY / collectionView.bounds.height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func setScrollPosition() {
|
func setScrollPosition() {
|
||||||
guard let collectionView = collectionView
|
guard let collectionView = collectionView
|
||||||
else { return }
|
else { return }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user