mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Merge pull request #1835 from abarth/drag_start
Add the position at which drags start
This commit is contained in:
commit
5855f72202
@ -15,11 +15,11 @@ enum DragState {
|
||||
accepted
|
||||
}
|
||||
|
||||
typedef void GestureDragStartCallback();
|
||||
typedef void GestureDragStartCallback(ui.Point globalPosition);
|
||||
typedef void GestureDragUpdateCallback(double delta);
|
||||
typedef void GestureDragEndCallback(ui.Offset velocity);
|
||||
|
||||
typedef void GesturePanStartCallback();
|
||||
typedef void GesturePanStartCallback(ui.Point globalPosition);
|
||||
typedef void GesturePanUpdateCallback(ui.Offset delta);
|
||||
typedef void GesturePanEndCallback(ui.Offset velocity);
|
||||
|
||||
@ -43,6 +43,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
|
||||
GestureDragEndCallback onEnd;
|
||||
|
||||
DragState _state = DragState.ready;
|
||||
ui.Point _initialPosition;
|
||||
T _pendingDragDelta;
|
||||
|
||||
T get _initialPendingDragDelta;
|
||||
@ -56,6 +57,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
|
||||
_velocityTrackers[event.pointer] = new ui.VelocityTracker();
|
||||
if (_state == DragState.ready) {
|
||||
_state = DragState.possible;
|
||||
_initialPosition = event.position;
|
||||
_pendingDragDelta = _initialPendingDragDelta;
|
||||
}
|
||||
}
|
||||
@ -85,7 +87,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
|
||||
T delta = _pendingDragDelta;
|
||||
_pendingDragDelta = _initialPendingDragDelta;
|
||||
if (onStart != null)
|
||||
onStart();
|
||||
onStart(_initialPosition);
|
||||
if (delta != _initialPendingDragDelta && onUpdate != null)
|
||||
onUpdate(delta);
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ class _Drawer extends StatelessComponent {
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return new GestureDetector(
|
||||
onHorizontalDragStart: () {
|
||||
onHorizontalDragStart: (_) {
|
||||
if (interactive)
|
||||
route._takeControl();
|
||||
},
|
||||
|
||||
@ -115,7 +115,7 @@ class _DismissableState extends State<Dismissable> {
|
||||
_maybeCallOnResized();
|
||||
}
|
||||
|
||||
void _handleDragStart() {
|
||||
void _handleDragStart(_) {
|
||||
if (_fadePerformance.isAnimating)
|
||||
return;
|
||||
setState(() {
|
||||
|
||||
@ -239,7 +239,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
|
||||
_animation.stop();
|
||||
}
|
||||
|
||||
void _handleDragStart() {
|
||||
void _handleDragStart(_) {
|
||||
scheduleMicrotask(dispatchOnScrollStart);
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ void main() {
|
||||
TapGestureRecognizer tap = new TapGestureRecognizer(router: router);
|
||||
|
||||
bool didStartPan = false;
|
||||
pan.onStart = () {
|
||||
pan.onStart = (_) {
|
||||
didStartPan = true;
|
||||
};
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ void main() {
|
||||
bool didEndDrag = false;
|
||||
|
||||
Widget widget = new GestureDetector(
|
||||
onVerticalDragStart: () {
|
||||
onVerticalDragStart: (_) {
|
||||
didStartDrag = true;
|
||||
},
|
||||
onVerticalDragUpdate: (double scrollDelta) {
|
||||
@ -97,7 +97,7 @@ void main() {
|
||||
|
||||
tester.pumpWidget(
|
||||
new GestureDetector(
|
||||
onPanStart: () {
|
||||
onPanStart: (_) {
|
||||
didStartPan = true;
|
||||
},
|
||||
onPanUpdate: (Offset delta) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user