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:
parent
0e6b34513a
commit
5b548488ac
@ -19,6 +19,8 @@ class AlbumViewController: NSViewController,
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
albumScrollView.postsBoundsChangedNotifications = true
|
||||
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(updateAlbums(_:)),
|
||||
@ -73,5 +75,6 @@ class AlbumViewController: NSViewController,
|
||||
return NSSize(width: itemWidth, height: itemHeight)
|
||||
}
|
||||
|
||||
@IBOutlet var albumScrollView: NSScrollView!
|
||||
@IBOutlet var albumCollectionView: NSCollectionView!
|
||||
}
|
||||
|
||||
@ -31,15 +31,38 @@ class AlbumItemView: NSView {
|
||||
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) {
|
||||
playButton.isHidden = true
|
||||
hidePlayButton()
|
||||
}
|
||||
|
||||
override func mouseEntered(with event: NSEvent) {
|
||||
playButton.isHidden = false
|
||||
showPlayButton()
|
||||
}
|
||||
|
||||
override func mouseExited(with event: NSEvent) {
|
||||
hidePlayButton()
|
||||
}
|
||||
|
||||
func showPlayButton() {
|
||||
playButton.isHidden = false
|
||||
}
|
||||
|
||||
func hidePlayButton() {
|
||||
playButton.isHidden = true
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user