Skip to content

Let scrollOffsetCorrection on small lists not leave the list stuck in overscroll #17599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 18, 2018

Conversation

xster
Copy link
Member

@xster xster commented May 15, 2018

Fixes #17474

The issue is if offset corrections don't cause the viewport content's scroll extent to change, lists in overscroll can be stuck.

@xster xster requested a review from Hixie May 15, 2018 06:21
@@ -252,11 +252,13 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
/// see the discussion there for why that might still be a bad idea.)
void correctPixels(double value) {
_pixels = value;
_didChangeViewportDimensionOrPixels = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation says "In particular, this is typically called as a response to applyViewportDimension or applyContentDimensions", but here you're writing code that assumes it's called before applyContentDimensions, which seems dubious.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya, I'm a bit concerned touching something this central since there's a lot of implicit coupling, though all the tests passed.

I wasn't too sure what's the best way either. The correct behaviour seems to work with long lists because applyNewDimensions is called on line 426 to re-kick the start ballistic activity. Perhaps you have a better solution.

This field seemed like the least invasive as far as I can tell since the current code which uses the field instead of the setter seems to want to defer signaling after this loop here https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/rendering/viewport.dart#L1053. I'm assuming the documentation saying it's used in response to applyContentDimensions likely meant applyContentDimensions resets this value to false after consuming it.

Copy link
Member Author

Choose a reason for hiding this comment

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

PTAL, did what we talked about offline and added some docs and an assert.

@xster xster force-pushed the overscroll-stuck branch from 2192325 to 77ae250 Compare May 16, 2018 02:35
@@ -84,11 +84,6 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc
return super.setPixels(newPixels);
}

@override
void correctBy(double correction) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I left the correctPixels in the super alone like we talked about but this is an actual bug since it circumvents its super.correctBy and doesn't actually do anything different.

Copy link
Contributor

Choose a reason for hiding this comment

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

cool

///
/// See also:
///
/// * The method [correctBy], which is a method of [ViewportOffset] be used
Copy link
Contributor

Choose a reason for hiding this comment

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

-be

Copy link
Member Author

Choose a reason for hiding this comment

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

done

/// See also:
///
/// * The method [correctBy], which is a method of [ViewportOffset] be used
/// by viewport render objects to also correct the offset during layout
Copy link
Contributor

Choose a reason for hiding this comment

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

-also

Copy link
Member Author

Choose a reason for hiding this comment

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

done

/// See also:
///
/// * [jumpTo], for also changing the scroll position but applying the
/// change immediately and notifying its listeners.
Copy link
Contributor

Choose a reason for hiding this comment

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

mention that jumpTo is for when you're not in layout.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

///
/// See also:
///
/// * [correctBy], a more specialized way of changing the current offset
Copy link
Contributor

Choose a reason for hiding this comment

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

-more specialized (otherwise it makes it sound like jumpTo is also for use during layout)

Copy link
Member Author

Choose a reason for hiding this comment

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

done

void correctPixels(double value) {
_pixels = value;
}

// See also [correctPixels] which is used by the [ScrollPosition] itself to
// set the offset initially during construction or after
// [applyViewportDimension] or [applyContentDimensions] is called.
Copy link
Contributor

Choose a reason for hiding this comment

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

///?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I didn't realize dartdoc'ing overrides actually works. Done

Copy link
Contributor

Choose a reason for hiding this comment

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

oh we should also include the docs from the superclass, i didn't realize it was doing that. (These docs will replace the superclass docs.)

void correctPixels(double value) {
_pixels = value;
}

// See also [correctPixels] which is used by the [ScrollPosition] itself to
Copy link
Contributor

Choose a reason for hiding this comment

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

comma before "which"

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@Hixie
Copy link
Contributor

Hixie commented May 17, 2018

LGTM

@xster xster merged commit ef25052 into flutter:master May 18, 2018
@xster xster deleted the overscroll-stuck branch May 18, 2018 21:40
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CupertinoRefreshControl doesn't disappear in some cases
3 participants