Skip to content

Conversation

@Hixie
Copy link
Contributor

@Hixie Hixie commented Aug 6, 2020

It now uses the scroll metrics as they stood at the end of the last frame.

It previously used a weird combination of the old extents and the newish position, which led to some weird effects when the position had been changed in expectation of a viewport or content dimension change.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like it! This is what I was trying to do but it is a much simpler way of tracking it.

Copy link
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

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

lgtm

@Hixie
Copy link
Contributor Author

Hixie commented Aug 7, 2020

As it stands this breaks a bunch of tests. :-/ Investigating...

@Hixie Hixie force-pushed the scroll branch 2 times, most recently from 055dc79 to ca024e5 Compare August 7, 2020 21:44
@Hixie
Copy link
Contributor Author

Hixie commented Aug 7, 2020

Well it passes the tests now, at least.

@dannyvalentesonos
Copy link
Contributor

@Hixie I've stared testing with this patch, and so far so good. Thanks!

@Hixie
Copy link
Contributor Author

Hixie commented Aug 8, 2020

should some small epsilon be added to account for floating point error in case the new scroll extend is essentially the same but off by an epsilon due to some layout logic?

We definitely shouldn't just add epsilon, but maybe we could use nearEqual... I think we should wait until that's a real problem though.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should update the docs on RangeMaintainingScrollPhysics indicate that there are more cases where the range is not maintained.

It now uses the scroll metrics as they stood at the end of the last frame.

It previously used a weird combination of the old extents and the newish position, which led to some weird effects when the position had been changed in expectation of a viewport or content dimension change.
@Hixie
Copy link
Contributor Author

Hixie commented Aug 10, 2020

Added more documentation. Will land on green unless I hear otherwise. Thanks for the reviews!

@tvolkert tvolkert merged commit e3c7fb5 into flutter:master Aug 11, 2020
@tvolkert
Copy link
Contributor

Since this is a 1.20 cherrypick candidate, I landed on green.

@tvolkert
Copy link
Contributor

Fix for #60288

_pendingDimensions = false;
}
assert(!_didChangeViewportDimensionOrReceiveCorrection, 'Use correctForNewDimensions() (and return true) to change the scroll offset during applyContentDimensions().');
_lastMetrics = copyWith();
Copy link
Member

@xu-baolin xu-baolin Sep 1, 2020

Choose a reason for hiding this comment

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

Nice fixed!
We can not use the oldPosition above, for example, the _PagePosition.applyViewportDimension will correct the pixels due to resizing from zero, and it will cause RangeMaintainingScrollPhysics.adjustPositionForNewDimensions mistake. I am currently fix this bug (#65015 ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this as-is in my reland and will let you follow up in #65015 (i'll review that shortly, sorry i missed that until now)

}
}
if ((oldPosition.pixels < oldPosition.minScrollExtent) &&
(oldPosition.pixels > oldPosition.maxScrollExtent)) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be

if ((oldPosition.pixels < oldPosition.minScrollExtent) ||
        (oldPosition.pixels > oldPosition.maxScrollExtent))

right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wow, how did that not get caught by the tests, yikes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixing it doesn't cause any test failures even! what on earth.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in #65135

///
/// The second is to enforce the boundary when the position is in range.
///
/// If the current velocity is zero, neither adjustment is made. The
Copy link
Member

Choose a reason for hiding this comment

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

If the current velocity is non-zero

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops. will fix in the reland.

mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
It now uses the scroll metrics as they stood at the end of the last frame.

It previously used a weird combination of the old extents and the newish position, which led to some weird effects when the position had been changed in expectation of a viewport or content dimension change.
Hixie added a commit to Hixie/flutter that referenced this pull request Sep 7, 2020
It now uses the scroll metrics as they stood at the end of the last frame.

It previously used a weird combination of the old extents and the newish position, which led to some weird effects when the position had been changed in expectation of a viewport or content dimension change.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants