• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Modeled after Android's ViewConfiguration:
6// https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/ViewConfiguration.java
7
8/// The time that must elapse before a tap gesture sends onTapDown, if there's
9/// any doubt that the gesture is a tap.
10const Duration kPressTimeout = Duration(milliseconds: 100);
11
12/// Maximum length of time between a tap down and a tap up for the gesture to be
13/// considered a tap. (Currently not honored by the TapGestureRecognizer.)
14// TODO(ianh): Remove this, or implement a hover-tap gesture recognizer which
15// uses this.
16const Duration kHoverTapTimeout = Duration(milliseconds: 150);
17
18/// Maximum distance between the down and up pointers for a tap. (Currently not
19/// honored by the [TapGestureRecognizer]; [PrimaryPointerGestureRecognizer],
20/// which TapGestureRecognizer inherits from, uses [kTouchSlop].)
21// TODO(ianh): Remove this or implement it correctly.
22const double kHoverTapSlop = 20.0; // Logical pixels
23
24/// The time before a long press gesture attempts to win.
25const Duration kLongPressTimeout = Duration(milliseconds: 500);
26
27/// The maximum time from the start of the first tap to the start of the second
28/// tap in a double-tap gesture.
29// TODO(ianh): In Android, this is actually the time from the first's up event
30// to the second's down event, according to the ViewConfiguration docs.
31const Duration kDoubleTapTimeout = Duration(milliseconds: 300);
32
33/// The minimum time from the end of the first tap to the start of the second
34/// tap in a double-tap gesture.
35const Duration kDoubleTapMinTime = Duration(milliseconds: 40);
36
37/// The maximum distance that the first touch in a double-tap gesture can travel
38/// before deciding that it is not part of a double-tap gesture.
39/// DoubleTapGestureRecognizer also restricts the second touch to this distance.
40const double kDoubleTapTouchSlop = kTouchSlop; // Logical pixels
41
42/// Distance between the initial position of the first touch and the start
43/// position of a potential second touch for the second touch to be considered
44/// the second touch of a double-tap gesture.
45const double kDoubleTapSlop = 100.0; // Logical pixels
46
47/// The time for which zoom controls (e.g. in a map interface) are to be
48/// displayed on the screen, from the moment they were last requested.
49const Duration kZoomControlsTimeout = Duration(milliseconds: 3000);
50
51/// The distance a touch has to travel for the framework to be confident that
52/// the gesture is a scroll gesture, or, inversely, the maximum distance that a
53/// touch can travel before the framework becomes confident that it is not a
54/// tap.
55///
56/// A total delta less than or equal to [kTouchSlop] is not considered to be a
57/// drag, whereas if the delta is greater than [kTouchSlop] it is considered to
58/// be a drag.
59// This value was empirically derived. We started at 8.0 and increased it to
60// 18.0 after getting complaints that it was too difficult to hit targets.
61const double kTouchSlop = 18.0; // Logical pixels
62
63/// The distance a touch has to travel for the framework to be confident that
64/// the gesture is a paging gesture. (Currently not used, because paging uses a
65/// regular drag gesture, which uses kTouchSlop.)
66// TODO(ianh): Create variants of HorizontalDragGestureRecognizer et al for
67// paging, which use this constant.
68const double kPagingTouchSlop = kTouchSlop * 2.0; // Logical pixels
69
70/// The distance a touch has to travel for the framework to be confident that
71/// the gesture is a panning gesture.
72const double kPanSlop = kTouchSlop * 2.0; // Logical pixels
73
74/// The distance a touch has to travel for the framework to be confident that
75/// the gesture is a scale gesture.
76const double kScaleSlop = kTouchSlop; // Logical pixels
77
78/// The margin around a dialog, popup menu, or other window-like widget inside
79/// which we do not consider a tap to dismiss the widget. (Not currently used.)
80// TODO(ianh): Make ModalBarrier support this.
81const double kWindowTouchSlop = 16.0; // Logical pixels
82
83/// The minimum velocity for a touch to consider that touch to trigger a fling
84/// gesture.
85// TODO(ianh): Make sure nobody has their own version of this.
86const double kMinFlingVelocity = 50.0; // Logical pixels / second
87// const Velocity kMinFlingVelocity = const Velocity(pixelsPerSecond: 50.0);
88
89/// Drag gesture fling velocities are clipped to this value.
90// TODO(ianh): Make sure nobody has their own version of this.
91const double kMaxFlingVelocity = 8000.0; // Logical pixels / second
92
93/// The maximum time from the start of the first tap to the start of the second
94/// tap in a jump-tap gesture.
95// TODO(ianh): Implement jump-tap gestures.
96const Duration kJumpTapTimeout = Duration(milliseconds: 500);
97