mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixed tabs fling velocity threshold (#5990)
This commit is contained in:
parent
d3efe7da5e
commit
d3f540d4bd
@ -37,10 +37,9 @@ const Duration _kTabBarScroll = const Duration(milliseconds: 200);
|
||||
const Curve _kTabIndicatorLeadingCurve = Curves.easeOut;
|
||||
const Curve _kTabIndicatorTrailingCurve = Curves.easeIn;
|
||||
|
||||
// The scrollOffset (velocity) provided to fling() is pixels/ms, and the
|
||||
// tolerance velocity is pixels/sec. The additional factor of 5 is to further
|
||||
// increase sensitivity to swipe gestures and was determined "experimentally".
|
||||
final double _kMinFlingVelocity = kPixelScrollTolerance.velocity / 5000.0;
|
||||
// The additional factor of 5 is to further increase sensitivity to swipe
|
||||
// gestures and was determined "experimentally".
|
||||
final double _kMinFlingVelocity = kPixelScrollTolerance.velocity / 5.0;
|
||||
|
||||
class _TabBarParentData extends ContainerBoxParentDataMixin<RenderBox> { }
|
||||
|
||||
|
||||
@ -171,7 +171,7 @@ void main() {
|
||||
|
||||
// Fling-scroll the TabBar to the left
|
||||
expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(700.0));
|
||||
await tester.fling(find.byKey(tabBarKey), const Offset(-20.0, 0.0), 1000.0);
|
||||
await tester.fling(find.byKey(tabBarKey), const Offset(-200.0, 0.0), 10000.0);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
|
||||
expect(tester.getCenter(find.text('HHHHHH')).x, lessThan(500.0));
|
||||
@ -267,7 +267,7 @@ void main() {
|
||||
|
||||
// Fling to the left, switch from the 'LEFT' tab to the 'RIGHT'
|
||||
Point flingStart = tester.getCenter(find.text('LEFT CHILD'));
|
||||
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), 1000.0);
|
||||
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), 10000.0);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
|
||||
expect(selection.value, equals('RIGHT'));
|
||||
@ -276,7 +276,7 @@ void main() {
|
||||
|
||||
// Fling to the right, switch back to the 'LEFT' tab
|
||||
flingStart = tester.getCenter(find.text('RIGHT CHILD'));
|
||||
await tester.flingFrom(flingStart, new Offset(200.0, 0.0), 1000.0);
|
||||
await tester.flingFrom(flingStart, new Offset(200.0, 0.0), 10000.0);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
|
||||
expect(selection.value, equals('LEFT'));
|
||||
@ -301,7 +301,7 @@ void main() {
|
||||
// a change to the selected tab, everything should just settle back to
|
||||
// to where it started.
|
||||
Point flingStart = tester.getCenter(find.text('LEFT CHILD'));
|
||||
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), -1000.0);
|
||||
await tester.flingFrom(flingStart, new Offset(-200.0, 0.0), -10000.0);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(seconds: 1)); // finish the scroll animation
|
||||
expect(selection.value, equals('LEFT'));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user