flutter_map icon indicating copy to clipboard operation
flutter_map copied to clipboard

Mouse drag behaviour and fling damping

Open ben-milanko opened this issue 3 months ago • 4 comments

This PR makes some minor changes to the drag behaviour aimed at improving the experience on web and desktop.

First, if the cursor leaves the screen while dragging, the fling drag behaviour will send the map camera moving in the opposite direction.

Before:

https://github.com/user-attachments/assets/3307aacd-f0a9-4039-ae61-c221b69e3bbe

After:

https://github.com/user-attachments/assets/34cbb458-b9ac-4249-9996-94c9f38fbe29

Secondly, I would like to modify the damping behaviour of the fling for desktop users. This has been made part of the public API via InteractionOptions the default has been left per the current.

I've found a value of 2 is closer to the behaviour of Google Maps on web.

ben-milanko avatar Oct 18 '25 07:10 ben-milanko

Hey, thanks for submitting a PR! These look like good improvements.

It would be great if the new behaviour of reversing the direction of movement of the cursor leaves the edge of the screen was also toggleable. Does Google Maps and/or Leaflet on web behave the same way (sorry, I can't check right now)?

I'm not able to test any changes right now, but I'll review and hopefully merge once I return.

JaffaKetchup avatar Oct 22 '25 07:10 JaffaKetchup

Hey @JaffaKetchup , The current behaviour is that the fling reverses direction as the cursor leaves the screen. The new behaviour proposed in this PR is that the fling maintains its direction. This new behaviour matches what I can see in Leaflet and Google Maps.

ben-milanko avatar Oct 23 '25 08:10 ben-milanko

Ah sorry, misread! Ok, I'll have a look :)

JaffaKetchup avatar Oct 23 '25 09:10 JaffaKetchup

Hey thanks for looking at the PR @JaffaKetchup. I can see the issue from your videos.

The original issue with the rebound behaviour seems to still be there as well on the base branch, I don't think this was fixed. It's easier to replicate with the window moved to the edge of the screen.

I've added an additional tracked point so the fling can correctly use the last swiped direction for the fling rather than the direction from the start to end point. Are you okay with this change?

ben-milanko avatar Dec 06 '25 02:12 ben-milanko

Whoops, sorry, I'll try and review this soon.

JaffaKetchup avatar Dec 17 '25 11:12 JaffaKetchup