Commit 1e446ffc authored by Adam Barth's avatar Adam Barth

Add the position at which drags start

Fixes #1807
parent dc636679
...@@ -15,11 +15,11 @@ enum DragState { ...@@ -15,11 +15,11 @@ enum DragState {
accepted accepted
} }
typedef void GestureDragStartCallback(); typedef void GestureDragStartCallback(ui.Point globalPosition);
typedef void GestureDragUpdateCallback(double delta); typedef void GestureDragUpdateCallback(double delta);
typedef void GestureDragEndCallback(ui.Offset velocity); typedef void GestureDragEndCallback(ui.Offset velocity);
typedef void GesturePanStartCallback(); typedef void GesturePanStartCallback(ui.Point globalPosition);
typedef void GesturePanUpdateCallback(ui.Offset delta); typedef void GesturePanUpdateCallback(ui.Offset delta);
typedef void GesturePanEndCallback(ui.Offset velocity); typedef void GesturePanEndCallback(ui.Offset velocity);
...@@ -43,6 +43,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz ...@@ -43,6 +43,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
GestureDragEndCallback onEnd; GestureDragEndCallback onEnd;
DragState _state = DragState.ready; DragState _state = DragState.ready;
ui.Point _initialPosition;
T _pendingDragDelta; T _pendingDragDelta;
T get _initialPendingDragDelta; T get _initialPendingDragDelta;
...@@ -56,6 +57,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz ...@@ -56,6 +57,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
_velocityTrackers[event.pointer] = new ui.VelocityTracker(); _velocityTrackers[event.pointer] = new ui.VelocityTracker();
if (_state == DragState.ready) { if (_state == DragState.ready) {
_state = DragState.possible; _state = DragState.possible;
_initialPosition = event.position;
_pendingDragDelta = _initialPendingDragDelta; _pendingDragDelta = _initialPendingDragDelta;
} }
} }
...@@ -85,7 +87,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz ...@@ -85,7 +87,7 @@ abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecogniz
T delta = _pendingDragDelta; T delta = _pendingDragDelta;
_pendingDragDelta = _initialPendingDragDelta; _pendingDragDelta = _initialPendingDragDelta;
if (onStart != null) if (onStart != null)
onStart(); onStart(_initialPosition);
if (delta != _initialPendingDragDelta && onUpdate != null) if (delta != _initialPendingDragDelta && onUpdate != null)
onUpdate(delta); onUpdate(delta);
} }
......
...@@ -49,7 +49,7 @@ class _Drawer extends StatelessComponent { ...@@ -49,7 +49,7 @@ class _Drawer extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new GestureDetector( return new GestureDetector(
onHorizontalDragStart: () { onHorizontalDragStart: (_) {
if (interactive) if (interactive)
route._takeControl(); route._takeControl();
}, },
......
...@@ -115,7 +115,7 @@ class _DismissableState extends State<Dismissable> { ...@@ -115,7 +115,7 @@ class _DismissableState extends State<Dismissable> {
_maybeCallOnResized(); _maybeCallOnResized();
} }
void _handleDragStart() { void _handleDragStart(_) {
if (_fadePerformance.isAnimating) if (_fadePerformance.isAnimating)
return; return;
setState(() { setState(() {
......
...@@ -239,7 +239,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> { ...@@ -239,7 +239,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
_animation.stop(); _animation.stop();
} }
void _handleDragStart() { void _handleDragStart(_) {
scheduleMicrotask(dispatchOnScrollStart); scheduleMicrotask(dispatchOnScrollStart);
} }
......
...@@ -12,7 +12,7 @@ void main() { ...@@ -12,7 +12,7 @@ void main() {
TapGestureRecognizer tap = new TapGestureRecognizer(router: router); TapGestureRecognizer tap = new TapGestureRecognizer(router: router);
bool didStartPan = false; bool didStartPan = false;
pan.onStart = () { pan.onStart = (_) {
didStartPan = true; didStartPan = true;
}; };
......
...@@ -14,7 +14,7 @@ void main() { ...@@ -14,7 +14,7 @@ void main() {
bool didEndDrag = false; bool didEndDrag = false;
Widget widget = new GestureDetector( Widget widget = new GestureDetector(
onVerticalDragStart: () { onVerticalDragStart: (_) {
didStartDrag = true; didStartDrag = true;
}, },
onVerticalDragUpdate: (double scrollDelta) { onVerticalDragUpdate: (double scrollDelta) {
...@@ -97,7 +97,7 @@ void main() { ...@@ -97,7 +97,7 @@ void main() {
tester.pumpWidget( tester.pumpWidget(
new GestureDetector( new GestureDetector(
onPanStart: () { onPanStart: (_) {
didStartPan = true; didStartPan = true;
}, },
onPanUpdate: (Offset delta) { onPanUpdate: (Offset delta) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment