Commit 18e512d3 authored by Hans Muller's avatar Hans Muller

Replace Scroll with Drag in names in GestureRecognizer et al

parent e6d48ac5
...@@ -8,15 +8,15 @@ import 'package:sky/gestures/arena.dart'; ...@@ -8,15 +8,15 @@ import 'package:sky/gestures/arena.dart';
import 'package:sky/gestures/recognizer.dart'; import 'package:sky/gestures/recognizer.dart';
import 'package:sky/gestures/constants.dart'; import 'package:sky/gestures/constants.dart';
enum ScrollState { enum DragState {
ready, ready,
possible, possible,
accepted accepted
} }
typedef void GestureScrollStartCallback(); typedef void GestureDragStartCallback();
typedef void GestureScrollUpdateCallback(double scrollDelta); typedef void GestureDragUpdateCallback(double scrollDelta);
typedef void GestureScrollEndCallback(); typedef void GestureDragEndCallback();
typedef void GesturePanStartCallback(); typedef void GesturePanStartCallback();
typedef void GesturePanUpdateCallback(sky.Offset scrollDelta); typedef void GesturePanUpdateCallback(sky.Offset scrollDelta);
...@@ -24,39 +24,39 @@ typedef void GesturePanEndCallback(); ...@@ -24,39 +24,39 @@ typedef void GesturePanEndCallback();
typedef void _GesturePolymorphicUpdateCallback<T>(T scrollDelta); typedef void _GesturePolymorphicUpdateCallback<T>(T scrollDelta);
abstract class _ScrollGestureRecognizer<T extends dynamic> extends GestureRecognizer { abstract class _DragGestureRecognizer<T extends dynamic> extends GestureRecognizer {
_ScrollGestureRecognizer({ PointerRouter router, this.onStart, this.onUpdate, this.onEnd }) _DragGestureRecognizer({ PointerRouter router, this.onStart, this.onUpdate, this.onEnd })
: super(router: router); : super(router: router);
GestureScrollStartCallback onStart; GestureDragStartCallback onStart;
_GesturePolymorphicUpdateCallback<T> onUpdate; _GesturePolymorphicUpdateCallback<T> onUpdate;
GestureScrollEndCallback onEnd; GestureDragEndCallback onEnd;
ScrollState _state = ScrollState.ready; DragState _state = DragState.ready;
T _pendingScrollDelta; T _pendingDragDelta;
T get _initialPendingScrollDelta; T get _initialPendingDragDelta;
T _getScrollDelta(sky.PointerEvent event); T _getDragDelta(sky.PointerEvent event);
bool get _hasSufficientPendingScrollDeltaToAccept; bool get _hasSufficientPendingDragDeltaToAccept;
void addPointer(sky.PointerEvent event) { void addPointer(sky.PointerEvent event) {
startTrackingPointer(event.pointer); startTrackingPointer(event.pointer);
if (_state == ScrollState.ready) { if (_state == DragState.ready) {
_state = ScrollState.possible; _state = DragState.possible;
_pendingScrollDelta = _initialPendingScrollDelta; _pendingDragDelta = _initialPendingDragDelta;
} }
} }
void handleEvent(sky.PointerEvent event) { void handleEvent(sky.PointerEvent event) {
assert(_state != ScrollState.ready); assert(_state != DragState.ready);
if (event.type == 'pointermove') { if (event.type == 'pointermove') {
T delta = _getScrollDelta(event); T delta = _getDragDelta(event);
if (_state == ScrollState.accepted) { if (_state == DragState.accepted) {
if (onUpdate != null) if (onUpdate != null)
onUpdate(delta); onUpdate(delta);
} else { } else {
_pendingScrollDelta += delta; _pendingDragDelta += delta;
if (_hasSufficientPendingScrollDeltaToAccept) if (_hasSufficientPendingDragDeltaToAccept)
resolve(GestureDisposition.accepted); resolve(GestureDisposition.accepted);
} }
} }
...@@ -64,58 +64,58 @@ abstract class _ScrollGestureRecognizer<T extends dynamic> extends GestureRecogn ...@@ -64,58 +64,58 @@ abstract class _ScrollGestureRecognizer<T extends dynamic> extends GestureRecogn
} }
void acceptGesture(int pointer) { void acceptGesture(int pointer) {
if (_state != ScrollState.accepted) { if (_state != DragState.accepted) {
_state = ScrollState.accepted; _state = DragState.accepted;
T delta = _pendingScrollDelta; T delta = _pendingDragDelta;
_pendingScrollDelta = null; _pendingDragDelta = null;
if (onStart != null) if (onStart != null)
onStart(); onStart();
if (delta != _initialPendingScrollDelta && onUpdate != null) if (delta != _initialPendingDragDelta && onUpdate != null)
onUpdate(delta); onUpdate(delta);
} }
} }
void didStopTrackingLastPointer() { void didStopTrackingLastPointer() {
if (_state == ScrollState.possible) { if (_state == DragState.possible) {
resolve(GestureDisposition.rejected); resolve(GestureDisposition.rejected);
_state = ScrollState.ready; _state = DragState.ready;
return; return;
} }
bool wasAccepted = (_state == ScrollState.accepted); bool wasAccepted = (_state == DragState.accepted);
_state = ScrollState.ready; _state = DragState.ready;
if (wasAccepted && onEnd != null) if (wasAccepted && onEnd != null)
onEnd(); onEnd();
} }
} }
class VerticalScrollGestureRecognizer extends _ScrollGestureRecognizer<double> { class VerticalDragGestureRecognizer extends _DragGestureRecognizer<double> {
VerticalScrollGestureRecognizer({ VerticalDragGestureRecognizer({
PointerRouter router, PointerRouter router,
GestureScrollStartCallback onStart, GestureDragStartCallback onStart,
GestureScrollUpdateCallback onUpdate, GestureDragUpdateCallback onUpdate,
GestureScrollEndCallback onEnd GestureDragEndCallback onEnd
}) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd); }) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd);
double get _initialPendingScrollDelta => 0.0; double get _initialPendingDragDelta => 0.0;
// Notice that we negate dy because scroll offsets go in the opposite direction. // Notice that we negate dy because scroll offsets go in the opposite direction.
double _getScrollDelta(sky.PointerEvent event) => -event.dy; double _getDragDelta(sky.PointerEvent event) => -event.dy;
bool get _hasSufficientPendingScrollDeltaToAccept => _pendingScrollDelta.abs() > kTouchSlop; bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
} }
class HorizontalScrollGestureRecognizer extends _ScrollGestureRecognizer<double> { class HorizontalDragGestureRecognizer extends _DragGestureRecognizer<double> {
HorizontalScrollGestureRecognizer({ HorizontalDragGestureRecognizer({
PointerRouter router, PointerRouter router,
GestureScrollStartCallback onStart, GestureDragStartCallback onStart,
GestureScrollUpdateCallback onUpdate, GestureDragUpdateCallback onUpdate,
GestureScrollEndCallback onEnd GestureDragEndCallback onEnd
}) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd); }) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd);
double get _initialPendingScrollDelta => 0.0; double get _initialPendingDragDelta => 0.0;
double _getScrollDelta(sky.PointerEvent event) => -event.dx; double _getDragDelta(sky.PointerEvent event) => -event.dx;
bool get _hasSufficientPendingScrollDeltaToAccept => _pendingScrollDelta.abs() > kTouchSlop; bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragDelta.abs() > kTouchSlop;
} }
class PanGestureRecognizer extends _ScrollGestureRecognizer<sky.Offset> { class PanGestureRecognizer extends _DragGestureRecognizer<sky.Offset> {
PanGestureRecognizer({ PanGestureRecognizer({
PointerRouter router, PointerRouter router,
GesturePanStartCallback onStart, GesturePanStartCallback onStart,
...@@ -123,10 +123,10 @@ class PanGestureRecognizer extends _ScrollGestureRecognizer<sky.Offset> { ...@@ -123,10 +123,10 @@ class PanGestureRecognizer extends _ScrollGestureRecognizer<sky.Offset> {
GesturePanEndCallback onEnd GesturePanEndCallback onEnd
}) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd); }) : super(router: router, onStart: onStart, onUpdate: onUpdate, onEnd: onEnd);
sky.Offset get _initialPendingScrollDelta => sky.Offset.zero; sky.Offset get _initialPendingDragDelta => sky.Offset.zero;
// Notice that we negate dy because scroll offsets go in the opposite direction. // Notice that we negate dy because scroll offsets go in the opposite direction.
sky.Offset _getScrollDelta(sky.PointerEvent event) => new sky.Offset(event.dx, -event.dy); sky.Offset _getDragDelta(sky.PointerEvent event) => new sky.Offset(event.dx, -event.dy);
bool get _hasSufficientPendingScrollDeltaToAccept { bool get _hasSufficientPendingDragDeltaToAccept {
return _pendingScrollDelta.dx.abs() > kTouchSlop || _pendingScrollDelta.dy.abs() > kTouchSlop; return _pendingDragDelta.dx.abs() > kTouchSlop || _pendingDragDelta.dy.abs() > kTouchSlop;
} }
} }
...@@ -119,7 +119,7 @@ class Dismissable extends StatefulComponent { ...@@ -119,7 +119,7 @@ class Dismissable extends StatefulComponent {
_maybeCallOnResized(); _maybeCallOnResized();
} }
void _handleScrollStart() { void _handleDragStart() {
if (_fadePerformance.isAnimating) if (_fadePerformance.isAnimating)
return; return;
_dragUnderway = true; _dragUnderway = true;
...@@ -127,7 +127,7 @@ class Dismissable extends StatefulComponent { ...@@ -127,7 +127,7 @@ class Dismissable extends StatefulComponent {
_fadePerformance.progress = 0.0; _fadePerformance.progress = 0.0;
} }
void _handleScrollUpdate(double scrollOffset) { void _handleDragUpdate(double scrollOffset) {
if (!_isActive || _fadePerformance.isAnimating) if (!_isActive || _fadePerformance.isAnimating)
return; return;
...@@ -157,7 +157,7 @@ class Dismissable extends StatefulComponent { ...@@ -157,7 +157,7 @@ class Dismissable extends StatefulComponent {
_fadePerformance.progress = _dragExtent.abs() / (_size.width * _kDismissCardThreshold); _fadePerformance.progress = _dragExtent.abs() / (_size.width * _kDismissCardThreshold);
} }
_handleScrollEnd() { _handleDragEnd() {
if (!_isActive || _fadePerformance.isAnimating) if (!_isActive || _fadePerformance.isAnimating)
return; return;
_dragUnderway = false; _dragUnderway = false;
...@@ -238,12 +238,12 @@ class Dismissable extends StatefulComponent { ...@@ -238,12 +238,12 @@ class Dismissable extends StatefulComponent {
} }
return new GestureDetector( return new GestureDetector(
onHorizontalScrollStart: _directionIsYAxis ? null : _handleScrollStart, onHorizontalDragStart: _directionIsYAxis ? null : _handleDragStart,
onHorizontalScrollUpdate: _directionIsYAxis ? null : _handleScrollUpdate, onHorizontalDragUpdate: _directionIsYAxis ? null : _handleDragUpdate,
onHorizontalScrollEnd: _directionIsYAxis ? null : _handleScrollEnd, onHorizontalDragEnd: _directionIsYAxis ? null : _handleDragEnd,
onVerticalScrollStart: _directionIsYAxis ? _handleScrollStart : null, onVerticalDragStart: _directionIsYAxis ? _handleDragStart : null,
onVerticalScrollUpdate: _directionIsYAxis ? _handleScrollUpdate : null, onVerticalDragUpdate: _directionIsYAxis ? _handleDragUpdate : null,
onVerticalScrollEnd: _directionIsYAxis ? _handleScrollEnd : null, onVerticalDragEnd: _directionIsYAxis ? _handleDragEnd : null,
child: new Listener( child: new Listener(
onGestureFlingStart: _handleFlingStart, onGestureFlingStart: _handleFlingStart,
child: new SizeObserver( child: new SizeObserver(
......
...@@ -19,12 +19,12 @@ class GestureDetector extends StatefulComponent { ...@@ -19,12 +19,12 @@ class GestureDetector extends StatefulComponent {
this.onTap, this.onTap,
this.onShowPress, this.onShowPress,
this.onLongPress, this.onLongPress,
this.onVerticalScrollStart, this.onVerticalDragStart,
this.onVerticalScrollUpdate, this.onVerticalDragUpdate,
this.onVerticalScrollEnd, this.onVerticalDragEnd,
this.onHorizontalScrollStart, this.onHorizontalDragStart,
this.onHorizontalScrollUpdate, this.onHorizontalDragUpdate,
this.onHorizontalScrollEnd, this.onHorizontalDragEnd,
this.onPanStart, this.onPanStart,
this.onPanUpdate, this.onPanUpdate,
this.onPanEnd this.onPanEnd
...@@ -35,13 +35,13 @@ class GestureDetector extends StatefulComponent { ...@@ -35,13 +35,13 @@ class GestureDetector extends StatefulComponent {
GestureShowPressListener onShowPress; GestureShowPressListener onShowPress;
GestureLongPressListener onLongPress; GestureLongPressListener onLongPress;
GestureScrollStartCallback onVerticalScrollStart; GestureDragStartCallback onVerticalDragStart;
GestureScrollUpdateCallback onVerticalScrollUpdate; GestureDragUpdateCallback onVerticalDragUpdate;
GestureScrollEndCallback onVerticalScrollEnd; GestureDragEndCallback onVerticalDragEnd;
GestureScrollStartCallback onHorizontalScrollStart; GestureDragStartCallback onHorizontalDragStart;
GestureScrollUpdateCallback onHorizontalScrollUpdate; GestureDragUpdateCallback onHorizontalDragUpdate;
GestureScrollEndCallback onHorizontalScrollEnd; GestureDragEndCallback onHorizontalDragEnd;
GesturePanStartCallback onPanStart; GesturePanStartCallback onPanStart;
GesturePanUpdateCallback onPanUpdate; GesturePanUpdateCallback onPanUpdate;
...@@ -52,12 +52,12 @@ class GestureDetector extends StatefulComponent { ...@@ -52,12 +52,12 @@ class GestureDetector extends StatefulComponent {
onTap = source.onTap; onTap = source.onTap;
onShowPress = source.onShowPress; onShowPress = source.onShowPress;
onLongPress = source.onLongPress; onLongPress = source.onLongPress;
onVerticalScrollStart = source.onVerticalScrollStart; onVerticalDragStart = source.onVerticalDragStart;
onVerticalScrollUpdate = source.onVerticalScrollUpdate; onVerticalDragUpdate = source.onVerticalDragUpdate;
onVerticalScrollEnd = source.onVerticalScrollEnd; onVerticalDragEnd = source.onVerticalDragEnd;
onHorizontalScrollStart = source.onHorizontalScrollStart; onHorizontalDragStart = source.onHorizontalDragStart;
onHorizontalScrollUpdate = source.onHorizontalScrollUpdate; onHorizontalDragUpdate = source.onHorizontalDragUpdate;
onHorizontalScrollEnd = source.onHorizontalScrollEnd; onHorizontalDragEnd = source.onHorizontalDragEnd;
onPanStart = source.onPanStart; onPanStart = source.onPanStart;
onPanUpdate = source.onPanUpdate; onPanUpdate = source.onPanUpdate;
onPanEnd = source.onPanEnd; onPanEnd = source.onPanEnd;
...@@ -87,18 +87,18 @@ class GestureDetector extends StatefulComponent { ...@@ -87,18 +87,18 @@ class GestureDetector extends StatefulComponent {
return _longPress; return _longPress;
} }
VerticalScrollGestureRecognizer _verticalScroll; VerticalDragGestureRecognizer _verticalDrag;
VerticalScrollGestureRecognizer _ensureVerticalScroll() { VerticalDragGestureRecognizer _ensureVerticalDrag() {
if (_verticalScroll == null) if (_verticalDrag == null)
_verticalScroll = new VerticalScrollGestureRecognizer(router: _router); _verticalDrag = new VerticalDragGestureRecognizer(router: _router);
return _verticalScroll; return _verticalDrag;
} }
HorizontalScrollGestureRecognizer _horizontalScroll; HorizontalDragGestureRecognizer _horizontalDrag;
HorizontalScrollGestureRecognizer _ensureHorizontalScroll() { HorizontalDragGestureRecognizer _ensureHorizontalDrag() {
if (_horizontalScroll == null) if (_horizontalDrag == null)
_horizontalScroll = new HorizontalScrollGestureRecognizer(router: _router); _horizontalDrag = new HorizontalDragGestureRecognizer(router: _router);
return _horizontalScroll; return _horizontalDrag;
} }
PanGestureRecognizer _pan; PanGestureRecognizer _pan;
...@@ -118,8 +118,8 @@ class GestureDetector extends StatefulComponent { ...@@ -118,8 +118,8 @@ class GestureDetector extends StatefulComponent {
_tap = _ensureDisposed(_tap); _tap = _ensureDisposed(_tap);
_showPress = _ensureDisposed(_showPress); _showPress = _ensureDisposed(_showPress);
_longPress = _ensureDisposed(_longPress); _longPress = _ensureDisposed(_longPress);
_verticalScroll = _ensureDisposed(_verticalScroll); _verticalDrag = _ensureDisposed(_verticalDrag);
_horizontalScroll = _ensureDisposed(_horizontalScroll); _horizontalDrag = _ensureDisposed(_horizontalDrag);
_pan = _ensureDisposed(_pan); _pan = _ensureDisposed(_pan);
} }
...@@ -127,8 +127,8 @@ class GestureDetector extends StatefulComponent { ...@@ -127,8 +127,8 @@ class GestureDetector extends StatefulComponent {
_syncTap(); _syncTap();
_syncShowPress(); _syncShowPress();
_syncLongPress(); _syncLongPress();
_syncVerticalScroll(); _syncVerticalDrag();
_syncHorizontalScroll(); _syncHorizontalDrag();
_syncPan(); _syncPan();
} }
...@@ -153,25 +153,25 @@ class GestureDetector extends StatefulComponent { ...@@ -153,25 +153,25 @@ class GestureDetector extends StatefulComponent {
_ensureLongPress().onLongPress = onLongPress; _ensureLongPress().onLongPress = onLongPress;
} }
void _syncVerticalScroll() { void _syncVerticalDrag() {
if (onVerticalScrollStart == null && onVerticalScrollUpdate == null && onVerticalScrollEnd == null) { if (onVerticalDragStart == null && onVerticalDragUpdate == null && onVerticalDragEnd == null) {
_verticalScroll = _ensureDisposed(_verticalScroll); _verticalDrag = _ensureDisposed(_verticalDrag);
} else { } else {
_ensureVerticalScroll() _ensureVerticalDrag()
..onStart = onVerticalScrollStart ..onStart = onVerticalDragStart
..onUpdate = onVerticalScrollUpdate ..onUpdate = onVerticalDragUpdate
..onEnd = onVerticalScrollEnd; ..onEnd = onVerticalDragEnd;
} }
} }
void _syncHorizontalScroll() { void _syncHorizontalDrag() {
if (onHorizontalScrollStart == null && onHorizontalScrollUpdate == null && onHorizontalScrollEnd == null) { if (onHorizontalDragStart == null && onHorizontalDragUpdate == null && onHorizontalDragEnd == null) {
_horizontalScroll = _ensureDisposed(_horizontalScroll); _horizontalDrag = _ensureDisposed(_horizontalDrag);
} else { } else {
_ensureHorizontalScroll() _ensureHorizontalDrag()
..onStart = onHorizontalScrollStart ..onStart = onHorizontalDragStart
..onUpdate = onHorizontalScrollUpdate ..onUpdate = onHorizontalDragUpdate
..onEnd = onHorizontalScrollEnd; ..onEnd = onHorizontalDragEnd;
} }
} }
...@@ -198,10 +198,10 @@ class GestureDetector extends StatefulComponent { ...@@ -198,10 +198,10 @@ class GestureDetector extends StatefulComponent {
_showPress.addPointer(event); _showPress.addPointer(event);
if (_longPress != null) if (_longPress != null)
_longPress.addPointer(event); _longPress.addPointer(event);
if (_verticalScroll != null) if (_verticalDrag != null)
_verticalScroll.addPointer(event); _verticalDrag.addPointer(event);
if (_horizontalScroll != null) if (_horizontalDrag != null)
_horizontalScroll.addPointer(event); _horizontalDrag.addPointer(event);
if (_pan != null) if (_pan != null)
_pan.addPointer(event); _pan.addPointer(event);
return EventDisposition.processed; return EventDisposition.processed;
......
...@@ -85,10 +85,10 @@ abstract class Scrollable extends StatefulComponent { ...@@ -85,10 +85,10 @@ abstract class Scrollable extends StatefulComponent {
Widget build() { Widget build() {
return new GestureDetector( return new GestureDetector(
onVerticalScrollUpdate: scrollDirection == ScrollDirection.vertical ? scrollBy : null, onVerticalDragUpdate: scrollDirection == ScrollDirection.vertical ? scrollBy : null,
onVerticalScrollEnd: scrollDirection == ScrollDirection.vertical ? _maybeSettleScrollOffset : null, onVerticalDragEnd: scrollDirection == ScrollDirection.vertical ? _maybeSettleScrollOffset : null,
onHorizontalScrollUpdate: scrollDirection == ScrollDirection.horizontal ? scrollBy : null, onHorizontalDragUpdate: scrollDirection == ScrollDirection.horizontal ? scrollBy : null,
onHorizontalScrollEnd: scrollDirection == ScrollDirection.horizontal ? _maybeSettleScrollOffset : null, onHorizontalDragEnd: scrollDirection == ScrollDirection.horizontal ? _maybeSettleScrollOffset : null,
child: new Listener( child: new Listener(
child: buildContent(), child: buildContent(),
onPointerDown: _handlePointerDown, onPointerDown: _handlePointerDown,
......
...@@ -77,6 +77,8 @@ void dismissItem(WidgetTester tester, int item, { DismissDirection gestureDirect ...@@ -77,6 +77,8 @@ void dismissItem(WidgetTester tester, int item, { DismissDirection gestureDirect
downLocation = tester.getTopLeft(itemWidget); downLocation = tester.getTopLeft(itemWidget);
upLocation = tester.getBottomLeft(itemWidget); upLocation = tester.getBottomLeft(itemWidget);
break; break;
default:
fail("unsupported gestureDirection");
} }
TestPointer pointer = new TestPointer(5); TestPointer pointer = new TestPointer(5);
......
...@@ -9,49 +9,49 @@ void main() { ...@@ -9,49 +9,49 @@ void main() {
WidgetTester tester = new WidgetTester(); WidgetTester tester = new WidgetTester();
TestPointer pointer = new TestPointer(7); TestPointer pointer = new TestPointer(7);
bool didStartScroll = false; bool didStartDrag = false;
double updatedScrollDelta; double updatedDragDelta;
bool didEndScroll = false; bool didEndDrag = false;
Widget builder() { Widget builder() {
return new GestureDetector( return new GestureDetector(
onVerticalScrollStart: () { onVerticalDragStart: () {
didStartScroll = true; didStartDrag = true;
}, },
onVerticalScrollUpdate: (double scrollDelta) { onVerticalDragUpdate: (double scrollDelta) {
updatedScrollDelta = scrollDelta; updatedDragDelta = scrollDelta;
}, },
onVerticalScrollEnd: () { onVerticalDragEnd: () {
didEndScroll = true; didEndDrag = true;
}, },
child: new Container() child: new Container()
); );
} }
tester.pumpFrame(builder); tester.pumpFrame(builder);
expect(didStartScroll, isFalse); expect(didStartDrag, isFalse);
expect(updatedScrollDelta, isNull); expect(updatedDragDelta, isNull);
expect(didEndScroll, isFalse); expect(didEndDrag, isFalse);
Point firstLocation = new Point(10.0, 10.0); Point firstLocation = new Point(10.0, 10.0);
tester.dispatchEvent(pointer.down(firstLocation), firstLocation); tester.dispatchEvent(pointer.down(firstLocation), firstLocation);
expect(didStartScroll, isTrue); expect(didStartDrag, isTrue);
didStartScroll = false; didStartDrag = false;
expect(updatedScrollDelta, isNull); expect(updatedDragDelta, isNull);
expect(didEndScroll, isFalse); expect(didEndDrag, isFalse);
Point secondLocation = new Point(10.0, 9.0); Point secondLocation = new Point(10.0, 9.0);
tester.dispatchEvent(pointer.move(secondLocation), firstLocation); tester.dispatchEvent(pointer.move(secondLocation), firstLocation);
expect(didStartScroll, isFalse); expect(didStartDrag, isFalse);
expect(updatedScrollDelta, 1.0); expect(updatedDragDelta, 1.0);
updatedScrollDelta = null; updatedDragDelta = null;
expect(didEndScroll, isFalse); expect(didEndDrag, isFalse);
tester.dispatchEvent(pointer.up(), firstLocation); tester.dispatchEvent(pointer.up(), firstLocation);
expect(didStartScroll, isFalse); expect(didStartDrag, isFalse);
expect(updatedScrollDelta, isNull); expect(updatedDragDelta, isNull);
expect(didEndScroll, isTrue); expect(didEndDrag, isTrue);
didEndScroll = false; didEndDrag = false;
tester.pumpFrame(() => new Container()); tester.pumpFrame(() => new Container());
}); });
...@@ -68,10 +68,10 @@ void main() { ...@@ -68,10 +68,10 @@ void main() {
Widget builder() { Widget builder() {
return new GestureDetector( return new GestureDetector(
onVerticalScrollUpdate: (double delta) { dragDistance += delta; }, onVerticalDragUpdate: (double delta) { dragDistance += delta; },
onVerticalScrollEnd: () { gestureCount += 1; }, onVerticalDragEnd: () { gestureCount += 1; },
onHorizontalScrollUpdate: (_) { fail("gesture should not match"); }, onHorizontalDragUpdate: (_) { fail("gesture should not match"); },
onHorizontalScrollEnd: () { fail("gesture should not match"); }, onHorizontalDragEnd: () { fail("gesture should not match"); },
child: new Container() child: new Container()
); );
} }
......
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