You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mouse events are shifted after a css transform scale on the map container #6079
So I've just submitted a proposed PR ☝️ for this issue. The functionality works, but once I've had feedback I'll continue with the implementation and writing tests. Any eyes-on would be appreciated!
Reacted by Thomas Piller, Antonio Benvenuti and Andrew Harvey
@rgazelot unfortunately not as the conversation in #8017 means not using css transforms and rather going down the line of using offsetX and offsetY. However I don't believe this is a solid solution until there's a way to prevent panning/dragging when the mouse/cursor leaves the map bounds.
I have experimented with offsetX and offsetY based solution. While it does work and correctly returns local coordinates of an element inside CSS-transformed tree, it doesn't work for touch devices.
I understand that changing input model to pointers events could be a big switch, but hopefully the right one in the long term.
As potential mid-term patch we could experiment with firing a pointerdown event, let the browser do the transformation to local coordinates, and grab it back. I got this proof of concept working here https://output.jsbin.com/sadorac for almost all devices except Chrome for Android, which unlike other browser doesn't perform correct translation of clientX to offsetX on synthetic event.
Reacted by F.Moser, Adam Brewer and Ben Schattinger
@anvaka I had managed to implement an offsetX/Y for touch devices by providing a scale value, though only in my fork.
It's been well over a year since I've revisited this issue, but I think you're right in that pointer events could be the solution...if I remember correctly. I'm hoping that Sarafi is actually supported (as you say) 🤞
Activity
azei commentedon Apr 1, 2018
I'm running in to this issue as well. Scaling both shifts zooming in/out as well as making the map hard to pan.
Has anyone found a workaround?
adamcbrewer commentedon Jan 24, 2019
Same here, also struggling with this and the only way around that I can see is to write custom interactions for all scroll and touch events.
Perhaps a scale-offset property could be added to the API?
adamcbrewer commentedon Feb 21, 2019
Just a note, i've posted a possible solution to this issue in #7701 (comment).
adamcbrewer commentedon Mar 11, 2019
So I've just submitted a proposed PR ☝️ for this issue. The functionality works, but once I've had feedback I'll continue with the implementation and writing tests. Any eyes-on would be appreciated!
rgazelot commentedon Oct 30, 2019
Is there any update for this issue?
adamcbrewer commentedon Oct 30, 2019
@rgazelot unfortunately not as the conversation in #8017 means not using css transforms and rather going down the line of using
offsetXandoffsetY. However I don't believe this is a solid solution until there's a way to prevent panning/dragging when the mouse/cursor leaves the map bounds.rgazelot commentedon Oct 31, 2019
Thanks for the update @adamcbrewer
anvaka commentedon Nov 6, 2020
I have experimented with
offsetXandoffsetYbased solution. While it does work and correctly returns local coordinates of an element inside CSS-transformed tree, it doesn't work for touch devices.One promising direction to explore would be to use pointer events, like pointerdown. MDN reports this as not supported by Safari, however this simple test https://output.jsbin.com/garuceh worked in both iOS simulator's Safari and desktop Safari. It also worked in Firefox, Chrome for Android and desktop.
I understand that changing input model to pointers events could be a big switch, but hopefully the right one in the long term.
As potential mid-term patch we could experiment with firing a
pointerdownevent, let the browser do the transformation to local coordinates, and grab it back. I got this proof of concept working here https://output.jsbin.com/sadorac for almost all devices except Chrome for Android, which unlike other browser doesn't perform correct translation ofclientXtooffsetXon synthetic event.adamcbrewer commentedon Nov 10, 2020
@anvaka I had managed to implement an offsetX/Y for touch devices by providing a scale value, though only in my fork.
It's been well over a year since I've revisited this issue, but I think you're right in that pointer events could be the solution...if I remember correctly. I'm hoping that Sarafi is actually supported (as you say) 🤞
Fixed dom event coordinates for scaled container
Fix dom event coordinates for scaled container (#10096)