elm-maps
elm-maps copied to clipboard
Incorrect point of focus on zoom
SSCCE : https://ellie-app.com/3wZ5VGhhZa1/0
When zooming a map thats not positioned at the top left of a document the zoom doesn't follow the cursor position.
Possible cause is the use of clientX
and clientY
instead of offsetX
and offsetY
in this module : https://github.com/kennib/elm-maps/blob/master/src/Maps/Internal/Screen.elm#L117
MouseEvent offset info https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX
I've looked in to this a bit. Replacing clientX
and clientY
with offsetX
and offsetY
does fix the issue. You do have to set pointer-event: none;
on the image elements, if you don't the offset gets calculated from one of the images instead of the maps element.
Touch events don't have an offset
property so there has to be some sort of fallback decoder and it might be impossible to fix it properly without knowing the relative position of the maps element to te viewport.