1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Compare commits

..

No commits in common. "bc84d925d6dbc495796bc9cbb92d84dbbbcefb96" and "92366ac795c3254f5f8d8595ca45890cff85dbec" have entirely different histories.

3 changed files with 1 additions and 26 deletions

View File

@ -44,15 +44,6 @@ class AlbumViewController: NSViewController,
albumCollectionView.collectionViewLayout?.invalidateLayout() albumCollectionView.collectionViewLayout?.invalidateLayout()
} }
override func viewDidLayout() {
super.viewDidLayout()
guard let layout = albumCollectionView.collectionViewLayout as? AlbumViewLayout
else { return }
layout.setScrollPosition()
}
@objc func updateAlbums(_ notification: Notification) { @objc func updateAlbums(_ notification: Notification) {
guard let albums = notification.userInfo?[Notification.albumsKey] as? [MPDClient.Album] guard let albums = notification.userInfo?[Notification.albumsKey] as? [MPDClient.Album]
else { return } else { return }

View File

@ -11,7 +11,6 @@ import Cocoa
class AlbumViewLayout: NSCollectionViewFlowLayout { class AlbumViewLayout: NSCollectionViewFlowLayout {
let maxItemWidth: CGFloat = 180 let maxItemWidth: CGFloat = 180
let albumInfoHeight: CGFloat = 39 let albumInfoHeight: CGFloat = 39
var scrollPosition: CGFloat = 0
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
super.init() super.init()
@ -36,10 +35,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)
@ -51,11 +46,4 @@ class AlbumViewLayout: NSCollectionViewFlowLayout {
itemSize = NSSize(width: itemWidth, height: itemHeight) itemSize = NSSize(width: itemWidth, height: itemHeight)
} }
func setScrollPosition() {
guard let collectionView = collectionView
else { return }
collectionView.scroll(NSPoint(x: 0, y: scrollPosition * collectionView.bounds.height))
}
} }

View File

@ -43,7 +43,7 @@ class AlbumItemView: NSView {
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
self, self,
selector: #selector(viewDidScroll(_:)), selector: #selector(viewWillScroll(_:)),
name: NSScrollView.didLiveScrollNotification, name: NSScrollView.didLiveScrollNotification,
object: nil object: nil
) )
@ -59,10 +59,6 @@ class AlbumItemView: NSView {
hidePlayButton() hidePlayButton()
} }
@objc func viewDidScroll(_ notification: Notification) {
hidePlayButton()
}
override func resize(withOldSuperviewSize oldSize: NSSize) { override func resize(withOldSuperviewSize oldSize: NSSize) {
hidePlayButton() hidePlayButton()
} }