From bcbfdf8f5918127a688624b0a116da1f92d5a913 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 15 Dec 2015 14:37:52 -0800 Subject: [PATCH] Tabs should only scroll on a horizontal TabBarView fling --- packages/flutter/lib/src/material/tabs.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index adfaea89e9..64f886247b 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -31,6 +31,10 @@ const EdgeDims _kTabLabelPadding = const EdgeDims.symmetric(horizontal: 12.0); const double _kTabBarScrollDrag = 0.025; const Duration _kTabBarScroll = const Duration(milliseconds: 300); +// The scrollOffset (velocity) provided to fling() is pixels/ms, and the +// tolerance velocity is pixels/sec. +final double _kMinFlingVelocity = kPixelScrollTolerance.velocity / 2000.0; + class _TabBarParentData extends ContainerBoxParentDataMixin { } class _RenderTabBar extends RenderBox with @@ -756,7 +760,7 @@ class _TabBarViewState extends PageableListState> { if (config.selection.indexIsChanging) return new Future.value(); - if (scrollVelocity != Offset.zero) { + if (scrollVelocity.dx.abs() > _kMinFlingVelocity) { final int selectionDelta = scrollVelocity.dx > 0 ? -1 : 1; config.selection.index = (config.selection.index + selectionDelta).clamp(0, _tabCount - 1); return new Future.value();