fix scale & pan gestures conflict
This commit is contained in:
parent
f197159f8b
commit
4840b2744b
@ -529,6 +529,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
FFI.sendMouse('up', MouseButtons.left);
|
||||
}
|
||||
},
|
||||
// scale + pan event
|
||||
onTwoFingerScaleUpdate: (d) {
|
||||
FFI.canvasModel.updateScale(d.scale / _scale);
|
||||
_scale = d.scale;
|
||||
@ -538,10 +539,6 @@ class _RemotePageState extends State<RemotePage> {
|
||||
onTwoFingerScaleEnd: (d) => _scale = 1,
|
||||
onTwoFingerVerticalDragUpdate: (d) {
|
||||
FFI.scroll(d.delta.dy / 2);
|
||||
},
|
||||
onTwoFingerPanUpdate: (d) {
|
||||
FFI.canvasModel.panX(d.delta.dx);
|
||||
FFI.canvasModel.panY(d.delta.dy);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,6 @@ enum CustomTouchGestureState {
|
||||
twoFingerScale,
|
||||
twoFingerVerticalDrag,
|
||||
twoFingerHorizontalDrag,
|
||||
twoFingerPan
|
||||
}
|
||||
|
||||
const kScaleSlop = kPrecisePointerPanSlop / 15;
|
||||
@ -29,7 +28,7 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
||||
GestureDragUpdateCallback? onOneFingerPanUpdate;
|
||||
GestureDragEndCallback? onOneFingerPanEnd;
|
||||
|
||||
// twoFingerScale
|
||||
// twoFingerScale : scale + pan event
|
||||
GestureScaleStartCallback? onTwoFingerScaleStart;
|
||||
GestureScaleUpdateCallback? onTwoFingerScaleUpdate;
|
||||
GestureScaleEndCallback? onTwoFingerScaleEnd;
|
||||
@ -44,11 +43,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
||||
GestureDragUpdateCallback? onTwoFingerHorizontalDragUpdate;
|
||||
GestureDragEndCallback? onTwoFingerHorizontalDragEnd;
|
||||
|
||||
// twoFingerPan
|
||||
GestureDragStartCallback? onTwoFingerPanStart;
|
||||
GestureDragUpdateCallback? onTwoFingerPanUpdate;
|
||||
GestureDragEndCallback? onTwoFingerPanEnd;
|
||||
|
||||
void _init() {
|
||||
debugPrint("CustomTouchGestureRecognizer init");
|
||||
onStart = (d) {
|
||||
@ -94,11 +88,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
||||
onTwoFingerVerticalDragUpdate!(_getDragUpdateDetails(d));
|
||||
}
|
||||
break;
|
||||
case CustomTouchGestureState.twoFingerPan:
|
||||
if (onTwoFingerPanUpdate != null) {
|
||||
onTwoFingerPanUpdate!(_getDragUpdateDetails(d));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -133,12 +122,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
||||
onTwoFingerVerticalDragEnd!(_getDragEndDetails(d));
|
||||
}
|
||||
break;
|
||||
case CustomTouchGestureState.twoFingerPan:
|
||||
debugPrint("TwoFingerState.twoFingerPan onEnd");
|
||||
if (onTwoFingerPanEnd != null) {
|
||||
onTwoFingerPanEnd!(_getDragEndDetails(d));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -188,14 +171,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
||||
}
|
||||
_currentState = CustomTouchGestureState.twoFingerVerticalDrag;
|
||||
_reset();
|
||||
} else if ((_sumHorizontal.abs() + _sumVertical.abs()) >
|
||||
kPrecisePointerPanSlop) {
|
||||
debugPrint("start TwoFingerPan");
|
||||
_currentState = CustomTouchGestureState.twoFingerPan;
|
||||
if (onTwoFingerPanStart != null) {
|
||||
onTwoFingerPanStart!(_getDragStartDetails(d));
|
||||
}
|
||||
_reset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -806,9 +781,7 @@ RawGestureDetector getMixinGestureDetector({
|
||||
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
||||
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
||||
..onTwoFingerHorizontalDragUpdate = onTwoFingerHorizontalDragUpdate
|
||||
..onTwoFingerVerticalDragUpdate = onTwoFingerVerticalDragUpdate
|
||||
..onTwoFingerPanStart = onTwoFingerPanStart
|
||||
..onTwoFingerPanUpdate = onTwoFingerPanUpdate;
|
||||
..onTwoFingerVerticalDragUpdate = onTwoFingerVerticalDragUpdate;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user