Merge pull request #1835 from abarth/drag_start

Add the position at which drags start
This commit is contained in:
Adam Barth 2015-10-27 14:31:40 -07:00
commit 5855f72202
6 changed files with 11 additions and 9 deletions

View File

@ -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);
}

View File

@ -49,7 +49,7 @@ class _Drawer extends StatelessComponent {
Widget build(BuildContext context) {
return new GestureDetector(
onHorizontalDragStart: () {
onHorizontalDragStart: (_) {
if (interactive)
route._takeControl();
},

View File

@ -115,7 +115,7 @@ class _DismissableState extends State<Dismissable> {
_maybeCallOnResized();
}
void _handleDragStart() {
void _handleDragStart(_) {
if (_fadePerformance.isAnimating)
return;
setState(() {

View File

@ -239,7 +239,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
_animation.stop();
}
void _handleDragStart() {
void _handleDragStart(_) {
scheduleMicrotask(dispatchOnScrollStart);
}

View File

@ -12,7 +12,7 @@ void main() {
TapGestureRecognizer tap = new TapGestureRecognizer(router: router);
bool didStartPan = false;
pan.onStart = () {
pan.onStart = (_) {
didStartPan = true;
};

View File

@ -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) {