Mouse drag behaviour and fling damping
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.
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.
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.
Ah sorry, misread! Ok, I'll have a look :)
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?
Whoops, sorry, I'll try and review this soon.