mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Correct bottom overscroll in VariableHeightScrollable
Also updated the createDefaultScrollSimulation() springConstant and drag parameters to make non-overscroll fling scrolls slowdown faster and overscrolls snap back into place a little more snappily. R=abarth@chromium.org Review URL: https://codereview.chromium.org/1241733002 .
This commit is contained in:
parent
64c5420007
commit
05cd2e92ab
@ -49,8 +49,8 @@ class BoundedBehavior extends ScrollBehavior {
|
||||
Simulation createDefaultScrollSimulation(double position, double velocity, double minScrollOffset, double maxScrollOffset) {
|
||||
double velocityPerSecond = velocity * _kSecondsPerMillisecond;
|
||||
SpringDescription spring = new SpringDescription.withDampingRatio(
|
||||
mass: 1.0, springConstant: 85.0, ratio: 1.1);
|
||||
double drag = 0.4;
|
||||
mass: 1.0, springConstant: 170.0, ratio: 1.1);
|
||||
double drag = 0.025;
|
||||
return new ScrollSimulation(position, velocityPerSecond, minScrollOffset, maxScrollOffset, spring, drag);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ class OverscrollBehavior extends BoundedBehavior {
|
||||
// If we're overscrolling, we want move the scroll offset 2x
|
||||
// slower than we would otherwise. Therefore, we "rewind" the
|
||||
// newScrollOffset by half the amount that we moved it above.
|
||||
// Notice that we clap the "old" value to 0.0 so that we only
|
||||
// Notice that we clamp the "old" value to 0.0 so that we only
|
||||
// reduce the portion of scrollDelta that's applied beyond 0.0. We
|
||||
// do similar things for overscroll in the other direction.
|
||||
if (newScrollOffset < 0.0) {
|
||||
|
||||
@ -13,6 +13,7 @@ import 'package:sky/widgets/basic.dart';
|
||||
const double _kMillisecondsPerSecond = 1000.0;
|
||||
|
||||
double _velocityForFlingGesture(double eventVelocity) {
|
||||
// eventVelocity is pixels/second, config min,max limits are pixels/ms
|
||||
return eventVelocity.clamp(-config.kMaxFlingVelocity, config.kMaxFlingVelocity) /
|
||||
_kMillisecondsPerSecond;
|
||||
}
|
||||
|
||||
@ -19,9 +19,12 @@ class VariableHeightScrollable extends Scrollable {
|
||||
|
||||
IndexedBuilder builder;
|
||||
Object token;
|
||||
bool _contentsChanged = true;
|
||||
|
||||
void syncFields(VariableHeightScrollable source) {
|
||||
builder = source.builder;
|
||||
if (token != source.token)
|
||||
_contentsChanged = true;
|
||||
token = source.token;
|
||||
super.syncFields(source);
|
||||
}
|
||||
@ -40,9 +43,15 @@ class VariableHeightScrollable extends Scrollable {
|
||||
bool didReachLastChild
|
||||
) {
|
||||
assert(childOffsets.length > 0);
|
||||
scrollBehavior.contentsSize = didReachLastChild ? childOffsets.last : double.INFINITY;
|
||||
if (didReachLastChild && scrollOffset > scrollBehavior.maxScrollOffset)
|
||||
settleScrollOffset();
|
||||
if (didReachLastChild) {
|
||||
scrollBehavior.contentsSize = childOffsets.last;
|
||||
if (_contentsChanged && scrollOffset > scrollBehavior.maxScrollOffset) {
|
||||
_contentsChanged = false;
|
||||
settleScrollOffset();
|
||||
}
|
||||
} else {
|
||||
scrollBehavior.contentsSize = double.INFINITY;
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildContent() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user