|
|
|
@ -16,8 +16,29 @@ extension ParentPanelController: NSCollectionViewDataSource {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extension ParentPanelController { |
|
|
|
|
@IBAction func goForward(_: NSButton) { |
|
|
|
|
navigateModernSliderToSpecificIndex(1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@IBAction func goBackward(_: NSButton) { |
|
|
|
|
navigateModernSliderToSpecificIndex(-1) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func navigateModernSliderToSpecificIndex(_ index: Int) { |
|
|
|
|
let contentView = modernSlider.superview as! NSClipView |
|
|
|
|
let changedOrigin = contentView.documentVisibleRect.origin |
|
|
|
|
let newPoint = NSPoint(x: changedOrigin.x + contentView.frame.width / 2, y: changedOrigin.y) |
|
|
|
|
if let indexPath = modernSlider.indexPathForItem(at: newPoint) { |
|
|
|
|
let previousIndexPath = IndexPath(item: indexPath.item + index, section: indexPath.section) |
|
|
|
|
modernSlider.scrollToItems(at: Set([previousIndexPath]), scrollPosition: .centeredHorizontally) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@objc func collectionViewDidScroll(_ notification: NSNotification) { |
|
|
|
|
let contentView = notification.object as! NSClipView |
|
|
|
|
guard let contentView = notification.object as? NSClipView else { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let changedOrigin = contentView.documentVisibleRect.origin |
|
|
|
|
let newPoint = NSPoint(x: changedOrigin.x + contentView.frame.width / 2, y: changedOrigin.y) |
|
|
|
|
let indexPath = modernSlider.indexPathForItem(at: newPoint) |
|
|
|
|