From bee620c979fd990f3f22cc23f17aafdc949b530d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=B6ttcher?= Date: Tue, 28 Jun 2022 19:49:49 +0200 Subject: [PATCH] the zoom speed using the mouse wheel can be adjusted (#1289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * the zoom speed using the mouse wheel can be adjusted * fixed formatting Co-authored-by: Martin Böttcher --- lib/flutter_map.dart | 2 ++ lib/src/gestures/gestures.dart | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 5d7b2b3b1..a8d90ba3c 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -253,6 +253,7 @@ class MapOptions { /// his mouse. This is supported on web and desktop, but might also work well /// on Android. A [Listener] is used to capture the onPointerSignal events. final bool enableScrollWheel; + final double scrollWheelVelocity; final double? minZoom; final double? maxZoom; @@ -309,6 +310,7 @@ class MapOptions { this.pinchMoveWinGestures = MultiFingerGesture.pinchZoom | MultiFingerGesture.pinchMove, this.enableScrollWheel = true, + this.scrollWheelVelocity = 0.005, this.minZoom, this.maxZoom, this.interactiveFlags = InteractiveFlag.all, diff --git a/lib/src/gestures/gestures.dart b/lib/src/gestures/gestures.dart index 00e11ae44..cec76503e 100644 --- a/lib/src/gestures/gestures.dart +++ b/lib/src/gestures/gestures.dart @@ -58,7 +58,9 @@ abstract class MapGestureMixin extends State // Calculate new zoom level final minZoom = mapState.options.minZoom ?? 0.0; final maxZoom = mapState.options.maxZoom ?? double.infinity; - final newZoom = (mapState.zoom + pointerSignal.scrollDelta.dy * -0.005) + final newZoom = (mapState.zoom - + pointerSignal.scrollDelta.dy * + mapState.options.scrollWheelVelocity) .clamp(minZoom, maxZoom); // Calculate offset of mouse cursor from viewport center final List newCenterZoom = _getNewEventCenterZoomPosition(