Fix map jitter when touching map during follow-me animations

Cancel in-progress follow-me animations on pointer-down and suppress
new ones while any pointer is on the map. Without this, GPS position
updates trigger 600ms animateTo() calls that fight with the user's
stationary finger, causing visible wiggle — especially at low zoom
where small geographic shifts cover more pixels.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Doug Borg
2026-02-13 02:02:51 -07:00
co-authored by Claude Opus 4.6
parent c8e396a6eb
commit f0f23489b5
2 changed files with 50 additions and 29 deletions
+7 -2
View File
@@ -32,6 +32,7 @@ class GpsController {
List<OsmNode> Function()? _getNearbyNodes;
List<NodeProfile> Function()? _getEnabledProfiles;
VoidCallback? _onMapMovedProgrammatically;
bool Function()? _isUserInteracting;
/// Get the current GPS location (if available)
LatLng? get currentLocation => _currentLocation;
@@ -49,6 +50,7 @@ class GpsController {
required List<OsmNode> Function() getNearbyNodes,
required List<NodeProfile> Function() getEnabledProfiles,
VoidCallback? onMapMovedProgrammatically,
bool Function()? isUserInteracting,
}) async {
debugPrint('[GpsController] Initializing GPS controller');
@@ -61,7 +63,8 @@ class GpsController {
_getNearbyNodes = getNearbyNodes;
_getEnabledProfiles = getEnabledProfiles;
_onMapMovedProgrammatically = onMapMovedProgrammatically;
_isUserInteracting = isUserInteracting;
// Start location tracking
await _startLocationTracking();
}
@@ -235,9 +238,10 @@ class GpsController {
if (followMeMode == FollowMeMode.off || _mapController == null) {
return;
}
WidgetsBinding.instance.addPostFrameCallback((_) {
try {
if (_isUserInteracting?.call() == true) return;
if (followMeMode == FollowMeMode.follow) {
// Follow position, preserve rotation
_mapController!.animateTo(
@@ -352,5 +356,6 @@ class GpsController {
_getNearbyNodes = null;
_getEnabledProfiles = null;
_onMapMovedProgrammatically = null;
_isUserInteracting = null;
}
}