Skip to content

Conversation

@intonarumori
Copy link

@intonarumori intonarumori commented Aug 31, 2023

Moves the PanGestureRecognizer used to drag the content along both axis to the outer Scrollable subclass.

  • This solves the issue of the inner Scrollable gestures being disabled while the outer Scrollable is scrolling
  • Enables the user to stop the scroll movement by dragging the content again

Fixes: #133529

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

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 on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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.

@google-cla
Copy link

google-cla bot commented Aug 31, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Aug 31, 2023
@intonarumori intonarumori force-pushed the two-dimensional-scroll-dragging-fix branch from 392479a to a9347d4 Compare September 1, 2023 15:54
@HansMuller HansMuller requested a review from Piinks September 1, 2023 21:53
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hi @intonarumori thanks for contributing! This change will need tests to verify that it works as expected. Thank you!

@Piinks Piinks added the p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package label Sep 11, 2023
@intonarumori
Copy link
Author

intonarumori commented Sep 11, 2023

@Piinks Thanks for taking a look.

For tests my first idea was to look into the CustomScrollView tests and replicate them for the two dimensional version.
However, it looks like there is no concrete subclass of TwoDimensionalScrollView in the Flutter package, so I'm not sure that route would work.

/// It's rare to construct a [TwoDimensionalScrollable] directly. Instead,
/// consider subclassing [TwoDimensionalScrollView], which combines scrolling,
/// viewporting, and a layout model in both dimensions.

If you can give me some hints of how to go about testing this I would be happy to look into it.

@goderbauer goderbauer requested a review from Piinks September 19, 2023 22:07
@jtkeyva
Copy link

jtkeyva commented Sep 25, 2023

@intonarumori @Piinks any movement on this? Such a critical feature/bug fix. Does this also allow to scroll again to keep momentum / accelerate like in a regular scrollview?

Thanks

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Thanks for your patience. I appreciate you taking on a complex fix!

expect(scrollable.widget.dragStartBehavior, DragStartBehavior.down);
}, variant: TargetPlatformVariant.all());

testWidgets('Fling and tap to stop', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update these tests to check two more things? These should verify they we are actually scrolling when these taps occur. Can you add the following:

  • check the ScrollActivity.velocity in both axes when the test is about to tap and after.
    • the activity is available through the ScrollPosition
    • verifies we went from scrolling to stopping in response
  • we should also verify the position is actually changing/stops changing as a result of flinging and then stopping it with a tap.
    • verify the ScrollPosition.pixels before flinging, before tapping, and after tapping

case DiagonalDragBehavior.weightedContinuous:
case DiagonalDragBehavior.free:
verticalScrollable._handleDragEnd(verticalDragDetails);
//verticalScrollable._handleDragEnd(verticalDragDetails);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be removed?

// TwoDimensionalScrollableState.
return _configuration.buildOverscrollIndicator(context, child, details);
}
class _TwoDimensionalDragForwarding {
Copy link
Contributor

Choose a reason for hiding this comment

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

Public docs are not required for private classes (///), but can you add some docs to this for maintainers to better understand what it's for and where ti is used?

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hey @intonarumori are you planning to return to this and address the feedback above?

@jtkeyva
Copy link

jtkeyva commented Oct 18, 2023

almost there!

@Piinks Piinks added the package flutter/packages repository. See also p: labels. label Oct 19, 2023
@goderbauer goderbauer requested a review from Piinks November 7, 2023 23:06
@Piinks
Copy link
Contributor

Piinks commented Nov 13, 2023

We have not heard back from @intonarumori on this, so I am going to close it and open a new PR so we can close this bug. Thanks for contributing!

@Piinks Piinks closed this Nov 13, 2023
@jtkeyva
Copy link

jtkeyva commented Nov 14, 2023

@Piinks sounds good thanks. oh hey, nice video btw on this very feature :)

@Piinks Piinks reopened this Nov 14, 2023
@Piinks Piinks closed this Nov 14, 2023
Piinks added a commit to Piinks/flutter that referenced this pull request Nov 14, 2023
@Piinks Piinks mentioned this pull request Nov 14, 2023
8 tasks
@intonarumori
Copy link
Author

We have not heard back from @intonarumori on this, so I am going to close it and open a new PR so we can close this bug. Thanks for contributing!

@Piinks Sorry for the late reply, I've been bogged down by work lately and didn't have the time to come back to this.
Many thanks for taking on this. Looking forward to learn from the new one and hopefully land something better formatted next time.

auto-submit bot pushed a commit that referenced this pull request Nov 15, 2023
Adopted from #133750
That PR was abandoned. This finishes it up so we can land it.
Fixes #133529

Moves the `PanGestureRecognizer` used to drag the content along both axis to the outer vertical `Scrollable` subclass instead of the inner horizontal `Scrollable` subclass.

- This solves the issue of the inner `Scrollable` gestures being disabled while the outer `Scrollable` is scrolling
- Enables the user to stop the scroll movement by dragging the content again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package package flutter/packages repository. See also p: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[two_dimensional_scrollables] Scrolling doesn't stop on tap & Cannot accelerate scrolling on iOS and Android

3 participants