Skip to content

Implement Specific Fixes for Multi-Touch Scrolling Across Platforms - #138763

Closed
JacobSyndeo wants to merge 3 commits into
flutter:masterfrom
JacobSyndeo:multitouch-scroll-fix
Closed

JacobSyndeo wants to merge 3 commits into
flutter:masterfrom
JacobSyndeo:multitouch-scroll-fix

Conversation

@JacobSyndeo

@JacobSyndeo JacobSyndeo commented Nov 20, 2023 •

Copy link
Copy Markdown

Currently, when scrolling in Flutter with multiple fingers, the target platform's conventions are not respected. See #11884 and its discussion for an overview of the situation, as well as #38926 for further details.

This PR implements a solution as discussed here and here.

In short, it adds a new enum MultiTouchDragBehavior which allows customization of the way multiple finger inputs are treated during scrolling.

It includes .average, which implements iOS-style behavior, .last for Android-style behavior, .sum for legacy behavior, as well as a .first in case anyone really wants theirs to behave that way for some reason. It also includes a special .platformDefault, which lets Flutter decide which behavior is appropriate for the current platform.

Most of the modifications are in monodrag.dart.

Finally, this solution includes @xu-baolin's work on #136708 to support Android-style last-touch scroll behavior, albeit with slight modifications to play nice with more scrolling behaviors, such as the iOS-style .average, which is where most of my own effort here went.

Fixes #11884.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. f: gestures flutter/packages/flutter/gestures repository. labels Nov 20, 2023
@JacobSyndeo

JacobSyndeo commented Nov 20, 2023 •

Copy link
Copy Markdown
Author

I wanted to post this now for review and discussions' sake, but I'm currently having some difficulty writing unit tests for it.

I'm working in monodrag_test.dart, but in the test body, each pointer's update handler doesn't seem to provide easy access to the other pointer's activity, which presents a bit of a challenge.

This is my first contribution to Flutter, so if someone more familiar with the codebase could give me some pointers (heh) on how I should implement the unit tests here, then I'll be happy to build them out.

Also, as @xu-baolin's PR is still open, I'll leave it up to the maintainers to decide whether we should merge his in first, and adapt mine to his, or move forward with this one instead. I'm fine either way! I don't want to be rude or have bad etiquette here (especially as a new contributor); I just wanted to build out the solution for the iOS side, and then noticed that his PR fixed it on Android, and adapted his solution as MultiTouchDragBehavior.last here.

@xu-baolin

Copy link
Copy Markdown
Member

@JacobSyndeo Hi, Thank you very much for your contribution to the Flutter community.
Maybe we can wait for #136708 to land before extending the iOS behavior, and the separate features will also facilitate code review.
#106552 is a previous PR that implemented the iOS behavior. There are some comments inside for your reference.

@JacobSyndeo

Copy link
Copy Markdown
Author

@xu-baolin Thank you, sounds great. I'm looking forward to us as a community getting this longstanding issue resolved, so I'm happy to contribute!

Let's get yours merged in for now, then we can revisit the iOS side, as you said. That PR you linked is interesting, and may be better logic for the .average behavior than what I have here.

I still think there's value in the route you and I went down in our PRs, though, regarding adding an enum that allows different scroll behavior to be used, as well as retaining the legacy behavior (.sum) in case some apps depend on that.

Mine also adds .platformDefault, which we may end up wanting as well.

@goderbauer
goderbauer requested a review from Piinks November 21, 2023 23:14

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JacobSyndeo thanks for contributing! Per the last comment, and the other PR (#136708) that is addressing the issue, I am going to close this for now.

If there are separate/additional features to follow up on after that PR, we can take a look after that change lands.

Thanks very much for contributing!

@Piinks Piinks closed this Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: gestures flutter/packages/flutter/gestures repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scrolling with two fingers scrolls twice as fast

3 participants