Skip to content

Scrollwheel/trackpad scrolling for MacOS#5012

Open
RCCoop wants to merge 1 commit intoChartsOrg:masterfrom
RCCoop:scroll-wheel
Open

Scrollwheel/trackpad scrolling for MacOS#5012
RCCoop wants to merge 1 commit intoChartsOrg:masterfrom
RCCoop:scroll-wheel

Conversation

@RCCoop
Copy link
Copy Markdown

@RCCoop RCCoop commented Feb 22, 2023

Goals ⚽

Allow for scrolling around the chart on MacOS using two-finger trackpad scrolling, which is a more natural interaction than having to click and drag.

Implementation Details 🚧

Being new to this library, I may not be doing this the most elegant way, but I added override func scrollWheel(with:) to BarLineChartViewBase, and wrapped it with #if os(macOS). To implement the scrollWheel function, I mostly copied panGestureRecognized(_:), removing options that seemed specific to GestureRecognizer implementations, and replacing the translation and velocity calculations with NSEvent versions. The end result is that you can pan around in the view using two-finger trackpad scrolling.

Testing Details 🔍

I tested by using the ChartsDemo-macOS app in both BarDemoViewController and LineDemoViewController, each with and without dragDecelerationEnabled, to zoom and scroll. It was very simple testing, but it seemed to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant