-
Notifications
You must be signed in to change notification settings - Fork 26.7k
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
PageView ballistics overshoot the page on some devices #12884
Conversation
On some devices, such as Cupertino “Plus”-sized devices, scrolling left on the first page of a PageView will overshoot the first page and land on the second page. The issue is that applyContentDimensions incorrectly detects a content size change due to a floating point comparison on certain screen sizes (18257.400000000005 vs 18257.4) To fix this, perform a nearEqual comparison in applyContentDimensions.
@HansMuller is probably a good reviewer. Thanks for the patch! |
return (a == b); | ||
} else { | ||
return (a > (b - epsilon)) && (a < (b + epsilon)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write this as:
/// Whether two doubles are within a given distance of each other.
///
/// The `epsilon` argument must be positive and not null.
/// The `a` and `b` arguments may be null. A null value is
/// only considered near-equal to another null value.
 bool nearEqual(double a, double b, double epsilon) {
assert(epsilon != null);
 assert(epsilon >= 0.0);
if (a == null || b == null)
return a == b;
return (a > (b - epsilon)) && (a < (b + epsilon));
}
Thanks!
And thanks for the tests! |
@jwmcglynn Please let us know when you've updated the patch as suggested, and then we can land it. Thanks again! |
Hey @Hixie, I pushed a new commit that addresses your feedback. Thanks for the review! |
Thanks for the contribution! |
* PageView ballistics overshoot the page on some devices On some devices, such as Cupertino “Plus”-sized devices, scrolling left on the first page of a PageView will overshoot the first page and land on the second page. The issue is that applyContentDimensions incorrectly detects a content size change due to a floating point comparison on certain screen sizes (18257.400000000005 vs 18257.4) To fix this, perform a nearEqual comparison in applyContentDimensions. * Apply style changes to nearEqual for code review feedback.
On some devices, such as Cupertino “Plus”-sized devices, scrolling left on the first page of a PageView will overshoot the first page and land on the second page. Here is a gif that shows the problem:
The issue is that applyContentDimensions incorrectly detects a content size change due to a floating point comparison on certain screen sizes (18257.400000000005 vs 18257.4)
To fix this, perform a nearEqual comparison in applyContentDimensions.