Skip to content

Commit

Permalink
Allow trackpad swipe to scroll in Catalyst apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Schmitz committed Oct 27, 2023
1 parent e516b04 commit 720582e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Charts/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD

_panGestureRecognizer.delegate = self

// Allow trackpad swipe to scroll in Catalyst apps
#if targetEnvironment(macCatalyst)
if #available(iOS 13.4, macCatalyst 13.4, *) {
_panGestureRecognizer.allowedScrollTypesMask = .all
}
_panGestureRecognizer.maximumNumberOfTouches = 0
#endif

self.addGestureRecognizer(_tapGestureRecognizer)
self.addGestureRecognizer(_doubleTapGestureRecognizer)
self.addGestureRecognizer(_panGestureRecognizer)
Expand Down Expand Up @@ -677,7 +685,13 @@ open class BarLineChartViewBase: ChartViewBase, BarLineScatterCandleBubbleChartD

@objc private func panGestureRecognized(_ recognizer: NSUIPanGestureRecognizer)
{
if recognizer.state == NSUIGestureRecognizerState.began && recognizer.nsuiNumberOfTouches() > 0
// Allow trackpad swipe to scroll in Catalyst apps
#if targetEnvironment(macCatalyst)
let isBeginning = recognizer.state == NSUIGestureRecognizerState.began
#else
let isBeginning = recognizer.state == NSUIGestureRecognizerState.began && recognizer.nsuiNumberOfTouches() > 0
#endif
if isBeginning
{
stopDeceleration()

Expand Down

0 comments on commit 720582e

Please sign in to comment.