Skip to content

Conversation

@collinjackson
Copy link
Contributor

@collinjackson collinjackson commented Jul 20, 2017

Fixes #11322

Makes custom physics work with @HansMuller's new NestedScrollView demo.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need the clamping physics to make nested scroll view work. If you turn off the clamping, it'll go crazy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if I want to provide my own class that extends ClampingScrollPhysics? Should we require that the physics argument be a ClampingScrollPhysics?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we could just require that the physics extend ClampingScrollPhysics for this subclass.

@abarth may have opinions, the crazy physics inheritance magic is his baby. ;-)

@collinjackson
Copy link
Contributor Author

I've updated NestedScrollView to take a ClampingScrollPhysics.

Copy link
Contributor

Choose a reason for hiding this comment

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

this sentence's grammar got garbled, not sure what you meant exactly

Copy link
Contributor

Choose a reason for hiding this comment

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

Defaults to [ClampingScrollPhysics]. is probably better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Passing a custom class that extends [ClampingScrollPhysics] is allowed. is probably self-evident so I would omit it.
Maybe instead say something like The value must inherit from [ClampingScrollPhysics] and its [ScrollPhysics.applyBoundaryConditions] implementation should not allow scrolling outside the scroll extent range described by the [ScrollMetrics.minScrollExtent]/[ScrollMetrics.maxScrollExtent] properties passed to that method. If that invariant is not maintained, the nested scroll view may respond to user scrolling erratically. or some such.

Copy link
Contributor

Choose a reason for hiding this comment

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

You removed this sentence. Maybe consider bringing it back but having it point explicitly to [ScrollPhysics.createBallisticSimulation], which is the main method that one might want to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it, a better fix (which would allow us to skip all the stuff about forcing the user to use ClampingScrollPhysics et al) would be to just use const ClampingScrollPhysics().applyTo(physics) in the case where physics is non-null.

Copy link
Contributor

Choose a reason for hiding this comment

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

er, other way around I guess. physics.applyTo(const ClampingScrollPhysics()). Whichever way makes the physics that was passed in take priority. You'd still need to explicitly call out that you shouldn't override the clamping method, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works, so I made the change and reverted my other changes to documentation

@Hixie
Copy link
Contributor

Hixie commented Jul 21, 2017

LGTM

@collinjackson collinjackson merged commit e0f3001 into flutter:master Jul 21, 2017
@collinjackson collinjackson deleted the nsv_physics branch July 21, 2017 22:42
goderbauer added a commit that referenced this pull request Jul 24, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 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.

NestedScrollView should allow overriding the physics of the outer scroll view

3 participants