gesture updates for mobile
This commit is contained in:
@@ -110,6 +110,7 @@ class _FilamentGestureDetectorMobileState
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer? _scrollTimer;
|
Timer? _scrollTimer;
|
||||||
|
double _lastScale = 0;
|
||||||
|
|
||||||
// pinch zoom on mobile
|
// pinch zoom on mobile
|
||||||
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
||||||
@@ -133,33 +134,26 @@ class _FilamentGestureDetectorMobileState
|
|||||||
onScaleStart: (d) async {
|
onScaleStart: (d) async {
|
||||||
if (d.pointerCount == 2) {
|
if (d.pointerCount == 2) {
|
||||||
_scaling = true;
|
_scaling = true;
|
||||||
widget.controller.zoomBegin();
|
await widget.controller.zoomBegin();
|
||||||
} else if (!_scaling) {
|
} else if (!_scaling) {
|
||||||
if (_rotateOnPointerMove) {
|
if (_rotateOnPointerMove) {
|
||||||
widget.controller
|
widget.controller.rotateStart(
|
||||||
.rotateStart(d.focalPoint.dx, d.focalPoint.dy);
|
d.localFocalPoint.dx, d.localFocalPoint.dy);
|
||||||
} else {
|
} else {
|
||||||
widget.controller
|
widget.controller
|
||||||
.panStart(d.focalPoint.dx, d.focalPoint.dy);
|
.panStart(d.localFocalPoint.dx, d.localFocalPoint.dy);
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onScaleEnd: (d) async {
|
|
||||||
if (d.pointerCount == 2) {
|
|
||||||
widget.controller.zoomEnd();
|
|
||||||
_scaling = false;
|
|
||||||
} else if (!_scaling) {
|
|
||||||
if (_rotateOnPointerMove) {
|
|
||||||
widget.controller.rotateEnd();
|
|
||||||
} else {
|
|
||||||
widget.controller.panEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onScaleUpdate: (ScaleUpdateDetails d) async {
|
onScaleUpdate: (ScaleUpdateDetails d) async {
|
||||||
if (d.pointerCount == 2) {
|
if (d.pointerCount == 2) {
|
||||||
widget.controller.zoomUpdate(d.localFocalPoint.dx,
|
if (d.horizontalScale != _lastScale) {
|
||||||
d.localFocalPoint.dy, d.horizontalScale > 1 ? 0.1 : -0.1);
|
widget.controller.zoomUpdate(
|
||||||
|
d.localFocalPoint.dx,
|
||||||
|
d.localFocalPoint.dy,
|
||||||
|
d.horizontalScale > _lastScale ? 0.1 : -0.1);
|
||||||
|
_lastScale = d.horizontalScale;
|
||||||
|
}
|
||||||
} else if (!_scaling) {
|
} else if (!_scaling) {
|
||||||
if (_rotateOnPointerMove) {
|
if (_rotateOnPointerMove) {
|
||||||
widget.controller
|
widget.controller
|
||||||
@@ -170,6 +164,18 @@ class _FilamentGestureDetectorMobileState
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onScaleEnd: (d) async {
|
||||||
|
if (d.pointerCount == 2) {
|
||||||
|
widget.controller.zoomEnd();
|
||||||
|
} else if (!_scaling) {
|
||||||
|
if (_rotateOnPointerMove) {
|
||||||
|
widget.controller.rotateEnd();
|
||||||
|
} else {
|
||||||
|
widget.controller.panEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_scaling = false;
|
||||||
|
},
|
||||||
child: widget.child)),
|
child: widget.child)),
|
||||||
widget.showControlOverlay
|
widget.showControlOverlay
|
||||||
? Align(
|
? Align(
|
||||||
|
|||||||
Reference in New Issue
Block a user