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

Hide the album play button when scrolling starts

This commit is contained in:
Daniel Barber 2019-02-18 13:50:47 -05:00
parent 0e6b34513a
commit 5b548488ac
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 28 additions and 2 deletions

View File

@ -19,6 +19,8 @@ class AlbumViewController: NSViewController,
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
albumScrollView.postsBoundsChangedNotifications = true
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
self, self,
selector: #selector(updateAlbums(_:)), selector: #selector(updateAlbums(_:)),
@ -73,5 +75,6 @@ class AlbumViewController: NSViewController,
return NSSize(width: itemWidth, height: itemHeight) return NSSize(width: itemWidth, height: itemHeight)
} }
@IBOutlet var albumScrollView: NSScrollView!
@IBOutlet var albumCollectionView: NSCollectionView! @IBOutlet var albumCollectionView: NSCollectionView!
} }

View File

@ -31,15 +31,38 @@ class AlbumItemView: NSView {
addTrackingArea(trackingArea) addTrackingArea(trackingArea)
} }
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
NotificationCenter.default.addObserver(
self,
selector: #selector(viewWillScroll(_:)),
name: NSScrollView.willStartLiveScrollNotification,
object: nil
)
}
@objc func viewWillScroll(_ notification: Notification) {
hidePlayButton()
}
override func resize(withOldSuperviewSize oldSize: NSSize) { override func resize(withOldSuperviewSize oldSize: NSSize) {
playButton.isHidden = true hidePlayButton()
} }
override func mouseEntered(with event: NSEvent) { override func mouseEntered(with event: NSEvent) {
playButton.isHidden = false showPlayButton()
} }
override func mouseExited(with event: NSEvent) { override func mouseExited(with event: NSEvent) {
hidePlayButton()
}
func showPlayButton() {
playButton.isHidden = false
}
func hidePlayButton() {
playButton.isHidden = true playButton.isHidden = true
} }