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);
|
FFI.sendMouse('up', MouseButtons.left);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// scale + pan event
|
||||||
onTwoFingerScaleUpdate: (d) {
|
onTwoFingerScaleUpdate: (d) {
|
||||||
FFI.canvasModel.updateScale(d.scale / _scale);
|
FFI.canvasModel.updateScale(d.scale / _scale);
|
||||||
_scale = d.scale;
|
_scale = d.scale;
|
||||||
@ -538,10 +539,6 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
onTwoFingerScaleEnd: (d) => _scale = 1,
|
onTwoFingerScaleEnd: (d) => _scale = 1,
|
||||||
onTwoFingerVerticalDragUpdate: (d) {
|
onTwoFingerVerticalDragUpdate: (d) {
|
||||||
FFI.scroll(d.delta.dy / 2);
|
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,
|
twoFingerScale,
|
||||||
twoFingerVerticalDrag,
|
twoFingerVerticalDrag,
|
||||||
twoFingerHorizontalDrag,
|
twoFingerHorizontalDrag,
|
||||||
twoFingerPan
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const kScaleSlop = kPrecisePointerPanSlop / 15;
|
const kScaleSlop = kPrecisePointerPanSlop / 15;
|
||||||
@ -29,7 +28,7 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
GestureDragUpdateCallback? onOneFingerPanUpdate;
|
GestureDragUpdateCallback? onOneFingerPanUpdate;
|
||||||
GestureDragEndCallback? onOneFingerPanEnd;
|
GestureDragEndCallback? onOneFingerPanEnd;
|
||||||
|
|
||||||
// twoFingerScale
|
// twoFingerScale : scale + pan event
|
||||||
GestureScaleStartCallback? onTwoFingerScaleStart;
|
GestureScaleStartCallback? onTwoFingerScaleStart;
|
||||||
GestureScaleUpdateCallback? onTwoFingerScaleUpdate;
|
GestureScaleUpdateCallback? onTwoFingerScaleUpdate;
|
||||||
GestureScaleEndCallback? onTwoFingerScaleEnd;
|
GestureScaleEndCallback? onTwoFingerScaleEnd;
|
||||||
@ -44,11 +43,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
GestureDragUpdateCallback? onTwoFingerHorizontalDragUpdate;
|
GestureDragUpdateCallback? onTwoFingerHorizontalDragUpdate;
|
||||||
GestureDragEndCallback? onTwoFingerHorizontalDragEnd;
|
GestureDragEndCallback? onTwoFingerHorizontalDragEnd;
|
||||||
|
|
||||||
// twoFingerPan
|
|
||||||
GestureDragStartCallback? onTwoFingerPanStart;
|
|
||||||
GestureDragUpdateCallback? onTwoFingerPanUpdate;
|
|
||||||
GestureDragEndCallback? onTwoFingerPanEnd;
|
|
||||||
|
|
||||||
void _init() {
|
void _init() {
|
||||||
debugPrint("CustomTouchGestureRecognizer init");
|
debugPrint("CustomTouchGestureRecognizer init");
|
||||||
onStart = (d) {
|
onStart = (d) {
|
||||||
@ -94,11 +88,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
onTwoFingerVerticalDragUpdate!(_getDragUpdateDetails(d));
|
onTwoFingerVerticalDragUpdate!(_getDragUpdateDetails(d));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CustomTouchGestureState.twoFingerPan:
|
|
||||||
if (onTwoFingerPanUpdate != null) {
|
|
||||||
onTwoFingerPanUpdate!(_getDragUpdateDetails(d));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -133,12 +122,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
onTwoFingerVerticalDragEnd!(_getDragEndDetails(d));
|
onTwoFingerVerticalDragEnd!(_getDragEndDetails(d));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CustomTouchGestureState.twoFingerPan:
|
|
||||||
debugPrint("TwoFingerState.twoFingerPan onEnd");
|
|
||||||
if (onTwoFingerPanEnd != null) {
|
|
||||||
onTwoFingerPanEnd!(_getDragEndDetails(d));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -188,14 +171,6 @@ class CustomTouchGestureRecognizer extends ScaleGestureRecognizer {
|
|||||||
}
|
}
|
||||||
_currentState = CustomTouchGestureState.twoFingerVerticalDrag;
|
_currentState = CustomTouchGestureState.twoFingerVerticalDrag;
|
||||||
_reset();
|
_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
|
..onTwoFingerScaleUpdate = onTwoFingerScaleUpdate
|
||||||
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
..onTwoFingerScaleEnd = onTwoFingerScaleEnd
|
||||||
..onTwoFingerHorizontalDragUpdate = onTwoFingerHorizontalDragUpdate
|
..onTwoFingerHorizontalDragUpdate = onTwoFingerHorizontalDragUpdate
|
||||||
..onTwoFingerVerticalDragUpdate = onTwoFingerVerticalDragUpdate
|
..onTwoFingerVerticalDragUpdate = onTwoFingerVerticalDragUpdate;
|
||||||
..onTwoFingerPanStart = onTwoFingerPanStart
|
|
||||||
..onTwoFingerPanUpdate = onTwoFingerPanUpdate;
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user